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

DDMemMgr.h File Reference

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

Go to the source code of this file.

Typedefs

typedef DDMemMgr DDMemMgr
typedef DDMemMgr_Partition DDMemMgr_Partition

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)


Typedef Documentation

typedef struct DDMemMgr DDMemMgr
 

Definition at line 34 of file D3D7xDrv/DDMemMgr.h.

typedef struct DDMemMgr_Partition DDMemMgr_Partition
 

Definition at line 35 of file D3D7xDrv/DDMemMgr.h.


Function Documentation

DDMemMgr* DDMemMgr_Create uint32  Size  ) 
 

Definition at line 48 of file D3D7xDrv/DDMemMgr.c.

00049 {
00050         DDMemMgr        *MemMgr;
00051 
00052         MemMgr = (DDMemMgr*)malloc(sizeof(DDMemMgr));
00053 
00054         if (!MemMgr)
00055                 return NULL;
00056 
00057         memset(MemMgr, 0, sizeof(DDMemMgr));
00058 
00059         MemMgr->TotalMem = Size;
00060         MemMgr->FreeMem = Size;
00061 
00062         return MemMgr;
00063 }

void DDMemMgr_Destroy DDMemMgr MemMgr  ) 
 

Definition at line 68 of file D3D7xDrv/DDMemMgr.c.

00069 {
00070         assert(MemMgr);
00071 
00072         free(MemMgr);
00073 }

uint32 DDMemMgr_GetFreeMem DDMemMgr MemMgr  ) 
 

Definition at line 93 of file D3D7xDrv/DDMemMgr.c.

00094 {
00095         assert(MemMgr);
00096         return MemMgr->FreeMem;
00097 }

geBoolean DDMemMgr_PartitionAllocMem DDMemMgr_Partition Partition,
uint32  Size
 

Definition at line 183 of file D3D7xDrv/DDMemMgr.c.

00184 {
00185         assert(Partition->Active);
00186 
00187         if (Partition->FreeMem < Size)
00188                 return GE_FALSE;
00189 
00190         Partition->FreeMem -= Size;
00191 
00192         assert(Partition->FreeMem >= 0);
00193 
00194         return GE_TRUE;
00195 }

DDMemMgr_Partition* DDMemMgr_PartitionCreate DDMemMgr MemMgr,
uint32  Size
 

Definition at line 102 of file D3D7xDrv/DDMemMgr.c.

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

void DDMemMgr_PartitionDestroy DDMemMgr_Partition Partition  ) 
 

Definition at line 139 of file D3D7xDrv/DDMemMgr.c.

00140 {
00141         assert(Partition);
00142         assert(Partition->Active);
00143 
00144         memset(Partition, 0, sizeof(DDMemMgr_Partition));
00145 }

uint32 DDMemMgr_PartitionGetFreeMem DDMemMgr_Partition Partition  ) 
 

Definition at line 172 of file D3D7xDrv/DDMemMgr.c.

00173 {
00174         assert(Partition);
00175         assert(Partition->FreeMem >= 0);
00176 
00177         return Partition->FreeMem;
00178 }

uint32 DDMemMgr_PartitionGetTotalMem DDMemMgr_Partition Partition  ) 
 

Definition at line 161 of file D3D7xDrv/DDMemMgr.c.

00162 {
00163         assert(Partition);
00164         assert(Partition->TotalMem >= 0);
00165 
00166         return Partition->TotalMem;
00167 }

void DDMemMgr_PartitionReset DDMemMgr_Partition Partition  ) 
 

Definition at line 150 of file D3D7xDrv/DDMemMgr.c.

00151 {
00152         assert(Partition->Active);
00153         assert(Partition->FreeMem >= 0);
00154 
00155         Partition->FreeMem = Partition->TotalMem;
00156 }

void DDMemMgr_Reset DDMemMgr MemMgr  ) 
 

Definition at line 78 of file D3D7xDrv/DDMemMgr.c.

00079 {
00080         int32           i;
00081 
00082         assert(MemMgr);
00083 
00084         MemMgr->FreeMem = MemMgr->TotalMem;
00085 
00086         for (i=0; i<DDMEMMGR_MAX_PARTITIONS; i++)
00087                 memset(&MemMgr->Partitions[i], 0, sizeof(DDMemMgr_Partition));
00088 }


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