Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
emalloc.cpp File Reference
`#include "emalloc.h"`
`#include "danerror.h"`
`#include <stdlib.h>`

Go to the source code of this file.

## Functions
void * | Emalloc (size_t Size)
void * | Erealloc (void *ptr, size_t size)
void | Efree (void *ptr)

## Function Documentation

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 | ) |

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 */