Skip to content

Commit d00df38

Browse files
authored
[GEN] Backport changes of mempool, rawfile, trim, widestring, wwstring from Zero Hour (#668)
1 parent 8edcde4 commit d00df38

File tree

8 files changed

+346
-330
lines changed

8 files changed

+346
-330
lines changed

Generals/Code/Libraries/Source/WWVegas/WWLib/RAWFILE.H

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,10 @@
4848

4949
// #include "win.h"
5050

51-
#ifdef _UNIX
5251
#include <stdio.h>
53-
#include "osdep.h"
54-
#define NULL_HANDLE NULL
55-
#define HANDLE_TYPE FILE*
56-
#else
57-
#define NULL_HANDLE INVALID_HANDLE_VALUE
58-
#define HANDLE_TYPE HANDLE
59-
#endif
60-
61-
#include "WWFILE.H"
52+
#define NULL_HANDLE NULL
53+
#define HANDLE_TYPE FILE*
54+
#include "WWFILE.H"
6255
#include "wwstring.h"
6356

6457

@@ -141,11 +134,7 @@ class RawFileClass : public FileClass
141134
/*
142135
** This is the low level DOS handle. A -1 indicates an empty condition.
143136
*/
144-
#ifdef _UNIX
145-
FILE* Handle;
146-
#else
147-
void * Handle;
148-
#endif
137+
FILE* Handle;
149138

150139
StringClass Filename;
151140

Generals/Code/Libraries/Source/WWVegas/WWLib/mempool.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* *
2727
* Author:: Greg Hjelstrom *
2828
* *
29-
* $Modtime:: 6/06/01 11:04a $*
29+
* $Modtime:: 9/26/01 3:11p $*
3030
* *
31-
* $Revision:: 7 $*
31+
* $Revision:: 9 $*
3232
* *
3333
*---------------------------------------------------------------------------------------------*
3434
* Functions: *
@@ -52,6 +52,8 @@
5252

5353
#include "bittype.h"
5454
#include "wwdebug.h"
55+
#include "mutex.h"
56+
#include <new.h>
5557
#include <stdlib.h>
5658
#include <stddef.h>
5759

@@ -92,6 +94,7 @@ class ObjectPoolClass
9294
uint32 * BlockListHead;
9395
int FreeObjectCount;
9496
int TotalObjectCount;
97+
FastCriticalSectionClass ObjectPoolCS;
9598

9699
};
97100

@@ -155,8 +158,7 @@ class AutoPoolClass
155158
** the class.
156159
*/
157160
#define DEFINE_AUTO_POOL(T,BLOCKSIZE) \
158-
ObjectPoolClass<T,BLOCKSIZE> AutoPoolClass<T,BLOCKSIZE>::Allocator
159-
161+
ObjectPoolClass<T,BLOCKSIZE> AutoPoolClass<T,BLOCKSIZE>::Allocator;
160162

161163

162164
/***********************************************************************************************
@@ -274,6 +276,8 @@ void ObjectPoolClass<T,BLOCK_SIZE>::Free_Object(T * obj)
274276
template<class T,int BLOCK_SIZE>
275277
T * ObjectPoolClass<T,BLOCK_SIZE>::Allocate_Object_Memory(void)
276278
{
279+
FastCriticalSectionClass::LockClass lock(ObjectPoolCS);
280+
277281
if ( FreeListHead == 0 ) {
278282

279283
// No free objects, allocate another block
@@ -296,6 +300,7 @@ T * ObjectPoolClass<T,BLOCK_SIZE>::Allocate_Object_Memory(void)
296300
T * obj = FreeListHead; // Get the next free object
297301
FreeListHead = *(T**)(FreeListHead); // Bump the Head
298302
FreeObjectCount--;
303+
299304
return obj;
300305
}
301306

@@ -315,6 +320,8 @@ T * ObjectPoolClass<T,BLOCK_SIZE>::Allocate_Object_Memory(void)
315320
template<class T,int BLOCK_SIZE>
316321
void ObjectPoolClass<T,BLOCK_SIZE>::Free_Object_Memory(T * obj)
317322
{
323+
FastCriticalSectionClass::LockClass lock(ObjectPoolCS);
324+
318325
WWASSERT(obj != NULL);
319326
*(T**)(obj) = FreeListHead; // Link to the Head
320327
FreeListHead = obj; // Set the Head

0 commit comments

Comments
 (0)