gml_Alloc.h File Reference


Detailed Description

Memory allocation / deallocation for objects / structures.

#include "gml/base/gml_Types.h"
#include "gml/base/gml_Errors.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.


Functions

template<class T>
void gml_Zero (T *ptr)
 Set all bytes in a data structure to zero.
template<class T>
void gml_ZeroArray (T *ptr, gml_TBlockSize size)
 Set all bytes of all structures in an array to zero.
template<class T>
gml_TError gml_Malloc (T *&ptr, gml_TBlockSize size=1)
 Allocate an array of size structures.
template<class T>
gml_TError gml_MallocAndZero (T *&ptr, gml_TBlockSize size=1)
 Allocate an array of size structures and zero it.
template<class T>
void gml_Free (T *&ptr)
 Release resources claimed by gml_Malloc().
template<class T>
void gml_TestAndFree (T *&ptr)
 Release resources claimed by gml_Malloc(), iff ptr is not NULL.
template<class T>
gml_TError gml_New (T *&object)
 Create a new instance of class T.
template<class T>
gml_TError gml_NewArray (T *&object, gml_TBlockSize size)
 Create a new array of instances of class T.
template<class T>
gml_TError gml_NewAndInit (T *&object)
 Create a new instance of class T and call its Init method.
template<class T>
gml_TError gml_NewAndInitArray (T *&object, gml_TBlockSize size)
 Create a new array of instances of class T, and call their Init method.
template<class T>
void gml_Delete (T *&object)
 Delete an instance of class T.
template<class T>
void gml_DeleteArray (T *&object)
 Delete an array of instances of class T.
template<class T>
void gml_DisposeAndDelete (T *&object)
 Same as gml_Delete(); The object's Dispose method will be called first.
template<class T>
void gml_DisposeAndDeleteArray (T *&object, gml_TBlockSize size)
 Same as gml_DeleteArray(); the objects' Dispose methods will be called first.
template<class T>
void gml_TestDisposeAndDelete (T *&object)
 Same as gml_DisposeAndDelete(); nothing will be done if object is NULL.
template<class T>
void gml_TestDisposeAndDeleteArray (T *&object, gml_TBlockSize size)
 Same as gml_DisposeAndDeleteArray() nothing will be done if object is NULL.
template<class T>
void gml_TestAndDelete (T *&object)
 Same as gml_Delete(); nothing will be done if object is NULL.
template<class T>
void gml_TestAndDeleteArray (T *&object)
 Same as gml_DeleteArray(); nothing will be done if object is NULL.
template<class T>
gml_TError gml_GetGlobalObject (T *&ref)
 Put in ref a reference to the global object of the class that ref is a pointer to.
template<class T>
void gml_ReleaseGlobalObject (T *&ref)
 If ref if not NULL, decrement the number of references to the global object of the class that ref is a pointer to.

Function Documentation

void gml_Zero ( T *  ptr  )  [inline]

Set all bytes in a data structure to zero.

Parameters:
[in] ptr a pointer to the operand structure

void gml_ZeroArray ( T *  ptr,
gml_TBlockSize  size 
) [inline]

Set all bytes of all structures in an array to zero.

Parameters:
[in] ptr a pointer to the operand array
[in] size the number of elements to zero

gml_TError gml_Malloc ( T *&  ptr,
gml_TBlockSize  size = 1 
) [inline]

Allocate an array of size structures.

Parameters:
[out] ptr the pointer in which the newly allocated address will be stored
[in] size the number of structures to allocate

gml_TError gml_MallocAndZero ( T *&  ptr,
gml_TBlockSize  size = 1 
) [inline]

Allocate an array of size structures and zero it.

Parameters:
[out] ptr the pointer in which the newly allocated address will be stored
[in] size the number of structures to allocate and zero
See also:
gml_Malloc() and gml_ZeroArray().

void gml_Free ( T *&  ptr  )  [inline]

Release resources claimed by gml_Malloc().

The pointer ptr will be set to NULL.

Parameters:
[in,out] ptr the pointer to the data to free

void gml_TestAndFree ( T *&  ptr  )  [inline]

Release resources claimed by gml_Malloc(), iff ptr is not NULL.

Parameters:
[in,out] ptr the pointer to the data to free

gml_TError gml_New ( T *&  object  )  [inline]

Create a new instance of class T.

Parameters:
[out] object will be set to the address of the new object.

gml_TError gml_NewArray ( T *&  object,
gml_TBlockSize  size 
) [inline]

Create a new array of instances of class T.

Parameters:
[out] object will be set to the address of the new array.
[in] size requested length of the array.

gml_TError gml_NewAndInit ( T *&  object  )  [inline]

Create a new instance of class T and call its Init method.

The Init method is called without arguments.

Parameters:
[out] object will be set to the address of the new object.

gml_TError gml_NewAndInitArray ( T *&  object,
gml_TBlockSize  size 
) [inline]

Create a new array of instances of class T, and call their Init method.

Parameters:
[out] object will be set to the address of the new array.
[in] size requested length of the array.

void gml_Delete ( T *&  object  )  [inline]

Delete an instance of class T.

Parameters:
[in,out] object the address of the object; will be set to NULL.

void gml_DeleteArray ( T *&  object  )  [inline]

Delete an array of instances of class T.

Parameters:
[in,out] object the address of the array; will be set to NULL.

gml_TError gml_GetGlobalObject ( T *&  ref  )  [inline]

Put in ref a reference to the global object of the class that ref is a pointer to.

If no global object of this class was allocated yet, do it.

Returns:
gml_cNoError on success

gml_gErrorMemFull on failure, or an error code from the Init initialisation method of the class.

void gml_ReleaseGlobalObject ( T *&  ref  )  [inline]

If ref if not NULL, decrement the number of references to the global object of the class that ref is a pointer to.

If this number becomes 0, dispose and delete the global object.

Postcondition:
ref is always NULL.

Generated on Tue Jun 12 14:03:28 2007 for gml by Doxygen 1.5.2.