tesseract  4.0.0-1-g2a2b
emalloc.cpp File Reference
#include "emalloc.h"
#include <cstdlib>
#include "errcode.h"

Go to the source code of this file.

Functions

void * Emalloc (int Size)
 
void * Erealloc (void *ptr, int size)
 
void Efree (void *ptr)
 

Function Documentation

◆ Efree()

void Efree ( void *  ptr)

Definition at line 45 of file emalloc.cpp.

45  {
46  ASSERT_HOST(ptr != nullptr);
47  free(ptr);
48 }
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ Emalloc()

void* Emalloc ( int  Size)

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.

Parameters
Sizenumber of bytes of memory to be allocated
Returns
Pointer to allocated memory.

Definition at line 31 of file emalloc.cpp.

31  {
32  ASSERT_HOST(Size > 0);
33  void* Buffer = malloc(Size);
34  ASSERT_HOST(Buffer != nullptr);
35  return Buffer;
36 }
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ Erealloc()

void* Erealloc ( void *  ptr,
int  size 
)

Definition at line 38 of file emalloc.cpp.

38  {
39  ASSERT_HOST(size > 0 || (size == 0 && ptr != nullptr));
40  void* Buffer = realloc(ptr, size);
41  ASSERT_HOST(Buffer != nullptr || size == 0);
42  return Buffer;
43 }
#define ASSERT_HOST(x)
Definition: errcode.h:84