|
tesseract 3.04.01
|
Go to the source code of this file.
Defines | |
| #define | NOTENOUGHMEMORY 2000 |
| #define | ILLEGALMALLOCREQUEST 2001 |
Functions | |
| void * | Emalloc (int Size) |
| void * | Erealloc (void *ptr, int size) |
| void | Efree (void *ptr) |
| #define NOTENOUGHMEMORY 2000 |
| void Efree | ( | void * | ptr | ) |
Definition at line 79 of file emalloc.cpp.
{
if (ptr == NULL)
DoError (ILLEGALMALLOCREQUEST, "Attempted to free NULL ptr");
free(ptr);
} /* Efree */
| void* Emalloc | ( | int | Size | ) |
---------------------------------------------------------------------------- Public Function Prototypes ----------------------------------------------------------------------------
This routine attempts to allocate the specified number of bytes. If the memory can be allocated, a pointer to the memory is returned. If the memory cannot be allocated, or if the allocation request is negative or zero, an error is trapped.
| Size | number of bytes of memory to be allocated |
Definition at line 47 of file emalloc.cpp.
{
void *Buffer;
if (Size <= 0)
DoError (ILLEGALMALLOCREQUEST, "Illegal malloc request size");
Buffer = (void *) malloc (Size);
if (Buffer == NULL) {
DoError (NOTENOUGHMEMORY, "Not enough memory");
return (NULL);
}
else
return (Buffer);
} /* Emalloc */
| void* Erealloc | ( | void * | ptr, |
| int | size | ||
| ) |
Definition at line 64 of file emalloc.cpp.
{
void *Buffer;
if (size < 0 || (size == 0 && ptr == NULL))
DoError (ILLEGALMALLOCREQUEST, "Illegal realloc request size");
Buffer = (void *) realloc (ptr, size);
if (Buffer == NULL && size != 0)
DoError (NOTENOUGHMEMORY, "Not enough memory");
return (Buffer);
} /* Erealloc */