version 1.2, 2002/05/06 02:23:23
|
version 1.3, 2002/05/06 16:10:27
|
|
|
#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) | #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) |
#include <windows.h> | #include <windows.h> |
#include <process.h> | #include <process.h> |
|
#include <stdio.h> |
#elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU) | #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU) |
#include <pthread.h> | #include <pthread.h> |
#include <semaphore.h> | #include <semaphore.h> |
|
|
#ifndef EINVAL | #ifndef EINVAL |
#define EINVAL WSAEINVAL | #define EINVAL WSAEINVAL |
#endif | #endif |
|
#define snprintf _snprintf |
typedef HANDLE PEGASUS_MUTEX_T; | typedef HANDLE PEGASUS_MUTEX_T; |
| |
#elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU) | #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU) |
|
|
| |
#endif | #endif |
| |
class PEGASUS_SUBALLOC_INTERNAL peg_suballocator |
|
|
class PEGASUS_SUBALLOC_LINKAGE peg_suballocator |
{ | { |
public: | public: |
static const int GUARD_SIZE = 0x10; |
|
static const int MAX_PATH_LEN = 0xff; |
|
static const int MAX_LINE_LEN = 0x14 ; |
|
static const int PRE_ALLOCATE = 0x00; |
|
static const int STEP_ALLOCATE = 0x01; |
|
| |
private: | private: |
peg_suballocator(const peg_suballocator &); | peg_suballocator(const peg_suballocator &); |
|
|
| |
PEGASUS_MUTEX_T globalSemHandle; | PEGASUS_MUTEX_T globalSemHandle; |
PEGASUS_MUTEX_T semHandles[3][16]; | PEGASUS_MUTEX_T semHandles[3][16]; |
static const Sint32 nodeSizes[][16]; |
static const Sint32 nodeSizes[3][16]; |
Uint32 allocs[][16]; |
Uint32 allocs[3][16]; |
Uint32 wastedBytes[][16]; |
Uint32 wastedBytes[3][16]; |
Uint32 inUse[][16]; |
Uint32 inUse[3][16]; |
Uint32 avail[][16] ; |
Uint32 avail[3][16] ; |
Uint32 totalAllocs; | Uint32 totalAllocs; |
Uint32 totalMemoryInUse; | Uint32 totalMemoryInUse; |
| |
|
|
void INSERT(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after); | void INSERT(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after); |
void INSERT_AFTER(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after); | void INSERT_AFTER(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after); |
void INSERT_BEFORE(SUBALLOC_NODE *new_node, SUBALLOC_NODE *before); | void INSERT_BEFORE(SUBALLOC_NODE *new_node, SUBALLOC_NODE *before); |
void DELETE(SUBALLOC_NODE *x); |
|
void _DELETE(SUBALLOC_NODE *x); | void _DELETE(SUBALLOC_NODE *x); |
Boolean IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node); | Boolean IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node); |
Boolean IS_FIRST(SUBALLOC_NODE *head, SUBALLOC_NODE *node); | Boolean IS_FIRST(SUBALLOC_NODE *head, SUBALLOC_NODE *node); |
|
|
x->next->prev = x->prev; | x->next->prev = x->prev; |
} | } |
| |
inline void peg_suballocator::DELETE(SUBALLOC_NODE *x) |
|
{ |
|
_DELETE(x); |
|
return; |
|
} |
|
|
|
inline Boolean peg_suballocator::IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node) | inline Boolean peg_suballocator::IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node) |
{ | { |
return ((node->prev == head && head->prev == node) ? true : false); | return ((node->prev == head && head->prev == node) ? true : false); |