Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

DDMemMgr.cpp File Reference

#include <Windows.h>
#include "BaseType.h"
#include "DDMemMgr.h"

Go to the source code of this file.

Compounds

struct  DDMemMgr
struct  DDMemMgr_Partition

Defines

#define DDMEMMGR_MAX_PARTITIONS   16

Typedefs

typedef DDMemMgr_Partition DDMemMgr_Partition
typedef DDMemMgr DDMemMgr

Functions

DDMemMgrDDMemMgr_Create (uint32 Size)
void DDMemMgr_Destroy (DDMemMgr *MemMgr)
void DDMemMgr_Reset (DDMemMgr *MemMgr)
uint32 DDMemMgr_GetFreeMem (DDMemMgr *MemMgr)
DDMemMgr_PartitionDDMemMgr_PartitionCreate (DDMemMgr *MemMgr, uint32 Size)
void DDMemMgr_PartitionDestroy (DDMemMgr_Partition *Partition)
void DDMemMgr_PartitionReset (DDMemMgr_Partition *Partition)
uint32 DDMemMgr_PartitionGetTotalMem (DDMemMgr_Partition *Partition)
uint32 DDMemMgr_PartitionGetFreeMem (DDMemMgr_Partition *Partition)
geBoolean DDMemMgr_PartitionAllocMem (DDMemMgr_Partition *Partition, uint32 Size)


Define Documentation

#define DDMEMMGR_MAX_PARTITIONS   16
 

Definition at line 36 of file DDMemMgr.cpp.


Typedef Documentation

typedef struct DDMemMgr DDMemMgr
 

typedef struct DDMemMgr_Partition DDMemMgr_Partition
 


Function Documentation

DDMemMgr* DDMemMgr_Create uint32  Size  ) 
 

Definition at line 56 of file DDMemMgr.cpp.

References DDMemMgr::FreeMem, MemMgr, NULL, and DDMemMgr::TotalMem.

00057 {
00058         DDMemMgr        *MemMgr;
00059 
00060         MemMgr = (DDMemMgr*)malloc(sizeof(DDMemMgr));
00061 
00062         if (!MemMgr)
00063                 return NULL;
00064 
00065         memset(MemMgr, 0, sizeof(DDMemMgr));
00066 
00067         MemMgr->TotalMem = Size;
00068         MemMgr->FreeMem = Size;
00069 
00070         return MemMgr;
00071 }

void DDMemMgr_Destroy DDMemMgr MemMgr  ) 
 

Definition at line 76 of file DDMemMgr.cpp.

References MemMgr.

00077 {
00078         free(MemMgr);
00079 }

uint32 DDMemMgr_GetFreeMem DDMemMgr MemMgr  ) 
 

Definition at line 97 of file DDMemMgr.cpp.

References DDMemMgr::FreeMem, MemMgr, and uint32.

00098 {
00099         return MemMgr->FreeMem;
00100 }

geBoolean DDMemMgr_PartitionAllocMem DDMemMgr_Partition Partition,
uint32  Size
 

Definition at line 166 of file DDMemMgr.cpp.

References DDMemMgr_Partition::FreeMem, GE_FALSE, GE_TRUE, geBoolean, and Partition.

00167 {
00168         if (Partition->FreeMem < Size)
00169                 return GE_FALSE;
00170 
00171         Partition->FreeMem -= Size;
00172 
00173         return GE_TRUE;
00174 }

DDMemMgr_Partition* DDMemMgr_PartitionCreate DDMemMgr MemMgr,
uint32  Size
 

Definition at line 105 of file DDMemMgr.cpp.

References DDMemMgr_Partition::Active, DDMEMMGR_MAX_PARTITIONS, DDMemMgr_Partition::FreeMem, DDMemMgr::FreeMem, GE_TRUE, int32, MemMgr, NULL, DDMemMgr::Partitions, and DDMemMgr_Partition::TotalMem.

00106 {
00107         int32                                   i;
00108         DDMemMgr_Partition              *pPartition;
00109 
00110         if (Size > MemMgr->FreeMem)
00111                 return NULL;
00112                 
00113         pPartition = MemMgr->Partitions;
00114 
00115         for (i=0; i< DDMEMMGR_MAX_PARTITIONS; i++, pPartition++)
00116         {
00117                 if (!pPartition->Active)
00118                 {
00119                         pPartition->TotalMem = Size;
00120                         pPartition->FreeMem = Size;
00121                         pPartition->Active = GE_TRUE;
00122                         MemMgr->FreeMem -= Size;
00123 
00124                         return pPartition;
00125                 }
00126         }
00127 
00128         return NULL;
00129 }

void DDMemMgr_PartitionDestroy DDMemMgr_Partition Partition  ) 
 

Definition at line 134 of file DDMemMgr.cpp.

References Partition.

00135 {
00136         memset(Partition, 0, sizeof(DDMemMgr_Partition));
00137 }

uint32 DDMemMgr_PartitionGetFreeMem DDMemMgr_Partition Partition  ) 
 

Definition at line 158 of file DDMemMgr.cpp.

References DDMemMgr_Partition::FreeMem, Partition, and uint32.

00159 {
00160         return Partition->FreeMem;
00161 }

uint32 DDMemMgr_PartitionGetTotalMem DDMemMgr_Partition Partition  ) 
 

Definition at line 150 of file DDMemMgr.cpp.

References Partition, DDMemMgr_Partition::TotalMem, and uint32.

00151 {
00152         return Partition->TotalMem;
00153 }

void DDMemMgr_PartitionReset DDMemMgr_Partition Partition  ) 
 

Definition at line 142 of file DDMemMgr.cpp.

References DDMemMgr_Partition::FreeMem, Partition, and DDMemMgr_Partition::TotalMem.

00143 {
00144         Partition->FreeMem = Partition->TotalMem;
00145 }

void DDMemMgr_Reset DDMemMgr MemMgr  ) 
 

Definition at line 84 of file DDMemMgr.cpp.

References DDMEMMGR_MAX_PARTITIONS, DDMemMgr::FreeMem, int32, MemMgr, DDMemMgr::Partitions, and DDMemMgr::TotalMem.

00085 {
00086         int32           i;
00087 
00088         MemMgr->FreeMem = MemMgr->TotalMem;
00089 
00090         for (i=0; i<DDMEMMGR_MAX_PARTITIONS; i++)
00091                 memset(&MemMgr->Partitions[i], 0, sizeof(DDMemMgr_Partition));
00092 }


Generated on Tue Sep 30 12:37:23 2003 for GTestAndEngine by doxygen 1.3.2