Tesseract
3.02
|
Go to the source code of this file.
Defines | |
#define | NOTENOUGHMEMORY 2000 |
#define | ILLEGALMALLOCREQUEST 2001 |
Functions | |
void * | Emalloc (size_t Size) |
void * | Erealloc (void *ptr, size_t size) |
void | Efree (void *ptr) |
#define NOTENOUGHMEMORY 2000 |
void Efree | ( | void * | ptr | ) |
Definition at line 85 of file emalloc.cpp.
{ if (ptr == NULL) DoError (ILLEGALMALLOCREQUEST, "Attempted to free NULL ptr"); free(ptr); } /* Efree */
void* Emalloc | ( | size_t | Size | ) |
---------------------------------------------------------------------------- Public Function Prototypes ----------------------------------------------------------------------------
---------------------------------------------------------------------------- Include Files and Type Defines ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- Public Code ----------------------------------------------------------------------------
Definition at line 35 of file emalloc.cpp.
{ /* ** Parameters: ** Size number of bytes of memory to be allocated ** Globals: none ** Operation: ** 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. ** Return: Pointer to allocated memory. ** Exceptions: NOTENOUGHMEMORY unable to allocate Size bytes ** ILLEGALMALLOCREQUEST negative or zero request size ** History: 4/3/89, DSJ, Created. */ 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, |
size_t | size | ||
) |
Definition at line 70 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 */