The following functions are to be used for internal allocation of small blocks in our allocator.
Return codes signalling an error are thrown as exceptions.
#define INTERNAL_MS_HEAP 0
#define INTERNAL_MS_CRTL 1
int itype = INTERNAL_MS_HEAP;
void *imalloc (unsigned size) {
switch (itype) {
case INTERNAL_MS_HEAP:
return ::HeapAlloc (::GetProcessHeap (), 0, size);
case INTERNAL_MS_CRTL:
return malloc (size);
}
return 0;
}
void *irealloc (void *ptr, unsigned size) {
switch (itype) {
case INTERNAL_MS_HEAP:
return ::HeapReAlloc (::GetProcessHeap (), 0, ptr, size);
case INTERNAL_MS_CRTL:
return realloc (ptr, size);
}
return 0;
}
void ifree (void *ptr) {
switch (itype) {
case INTERNAL_MS_HEAP:
if (! ::HeapFree (::GetProcessHeap (), 0, ptr))
throw COSException (__FILE__, __LINE__);
return;
case INTERNAL_MS_CRTL:
free (ptr);
return;
}
}
© 2000-2002 GeNeSys
mbH & Co. KG
Last revised: 12/14/2000