cutil/emalloc.cpp File Reference

#include "emalloc.h"
#include "danerror.h"
#include <stdlib.h>

Go to the source code of this file.

Functions


Function Documentation

void Efree ( void *  ptr  ) 

Attempts to free the specified pointer.

Parameters:
ptr Pointer to allocated memory
Returns:
none (but can
See also:
DoError)

Definition at line 90 of file emalloc.cpp.

References DoError(), ILLEGALMALLOCREQUEST, and NULL.

Referenced by EndDangerousAmbigs(), free_adapted_class(), free_adapted_templates(), free_int_class(), free_int_templates(), FreeCharDescription(), FreeMicroFeatures(), FreeNormProtos(), and LogNewWordChoice().

00090                       { 
00091   if (ptr == NULL)
00092     DoError (ILLEGALMALLOCREQUEST, "Attempted to free NULL ptr");
00093 
00094   free(ptr); 
00095 
00096 }                                /* Efree */

void* Emalloc ( size_t  Size  ) 

Attempts to allocate the specified number of bytes.

Parameters:
Size Number of bytes of memory to be allocated
Returns:
Pointer to allocated memory.
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.
Note:
Exceptions:
  • NOTENOUGHMEMORY unable to allocate Size bytes
  • ILLEGALMALLOCREQUEST negative or zero request size
Date:
4/3/89, DSJ, Created.

Definition at line 45 of file emalloc.cpp.

References DoError(), ILLEGALMALLOCREQUEST, NOTENOUGHMEMORY, and NULL.

Referenced by AddIntClass(), AddIntProto(), ComputeStatistics(), CreateClusterTree(), FillAmbigTable(), GetAmbiguities(), MakeBuckets(), MakeClusterer(), MakeHeap(), MakeKDNode(), MakeKDTree(), MakeNewCluster(), MakeSample(), MultipleCharSamples(), NewAdaptedClass(), NewAdaptedTemplates(), NewBitVector(), NewCharDescription(), NewChiStruct(), NewClass(), NewEllipticalProto(), NewFeatureSet(), NewIntClass(), NewIntTemplates(), NewLabeledClass(), NewLabeledList(), NewMicroFeature(), NewMixedProto(), NewSignalMenuItem(), NewSimpleProto(), NewViableChoice(), ReadAdaptedClass(), ReadAdaptedTemplates(), ReadConfigs(), ReadIntTemplates(), ReadNFloats(), ReadNormProtos(), ReadParamDesc(), ReadPermConfig(), ReadProtos(), ReadPrototype(), RemoveInsignificantProtos(), SetUpForClustering(), SetUpForFloat2Int(), and TestEllipticalProto().

00045                            { 
00046   void *Buffer;
00047 
00048   if (Size <= 0)
00049     DoError (ILLEGALMALLOCREQUEST, "Illegal malloc request size");
00050   Buffer = (void *) malloc (Size);
00051   if (Buffer == NULL) {
00052     DoError (NOTENOUGHMEMORY, "Not enough memory");
00053     return (NULL);
00054   }
00055   else
00056     return (Buffer);
00057 
00058 }                                /* Emalloc */

void* Erealloc ( void *  ptr,
size_t  size 
)

Attempts to reallocate the specified number of bytes.

Parameters:
ptr Pointer to allocated memory
size Number of bytes of memory to be reallocated
Returns:
Pointer to allocated memory.

Definition at line 69 of file emalloc.cpp.

References DoError(), ILLEGALMALLOCREQUEST, NOTENOUGHMEMORY, and NULL.

Referenced by AddConfigToClass(), AddIntProto(), AddProtoToClass(), and ExpandBitVector().

00069                                        { 
00070   void *Buffer;
00071 
00072   if (size < 0 || (size == 0 && ptr == NULL))
00073     DoError (ILLEGALMALLOCREQUEST, "Illegal realloc request size");
00074 
00075   Buffer = (void *) realloc (ptr, size);
00076   if (Buffer == NULL && size != 0)
00077     DoError (NOTENOUGHMEMORY, "Not enough memory");
00078   return (Buffer);
00079 
00080 }                                /* Erealloc */


Generated on Wed Feb 28 19:49:21 2007 for Tesseract by  doxygen 1.5.1