Header Header

Memory handling


Detailed Description

Functions for memory handling.


Defines

#define gx_globalrealloc_dbg(buf, sbuf, f, l)   gx_globalrealloc(buf,sbuf)
 Release/Debug workaround.
#define gx_globalalloc_dbg(buf, sbuf, f, l)   gx_globalalloc(buf,sbuf)
 Release/Debug workaround.

Functions

static int gx_globalrealloc (void **buffer, int sbuffer)
 Reallocates or frees a previously allocated memory area or allocates a new area.
static int gx_globalalloc (void **buffer, int sbuffer)
 Allocates a memory area that can be passed between modules.
static int gx_globalfree (void *buffer)
 Frees a previously allocated memory area.
static int gx_globalsize (int *sbuffer, void *buffer)
 Gets the size of a previously allocated memory area in bytes.
static int gx_globalrealloc_dbg (void **buffer, int sbuffer, const char *file, int line)
 Reallocates or frees a previously allocated memory area or allocates a new area (Debug version).
static int gx_globalalloc_dbg (void **buffer, int sbuffer, const char *file, int line)
 Allocates a memory area that can be passed between modules (Debug version).
static int gx_globalcheck_dbg ()
 Checks the memory consistency previously allocated with the gx_globalalloc() or gx_globalrealloc() functions (Debug version).
static int gx_globaltestmem_dbg (int index, char *fnbuffer, int fnbsize, char *membuffer, int mbsize, int *line, int *size, void **address)
 Returns details about the unfreed memory previously allocated with the gx_globalalloc() or gx_globalrealloc() functions (Debug version).
static int gx_creatememslot (int *handle, void **mem)
 Allocates a memory slot and returns a handle to it.
static int gx_getmemslot (int handle, void **mem)
 Returns the memory pointer to use on data update.
static int gx_unrefmemslot (int handle)
 Decrements the memory slot's reference counter.


Define Documentation

#define gx_globalrealloc_dbg ( buf,
sbuf,
f,
 )     gx_globalrealloc(buf,sbuf)

Release/Debug workaround.

Referenced by gx_globalalloc_dbg().

#define gx_globalalloc_dbg ( buf,
sbuf,
f,
 )     gx_globalalloc(buf,sbuf)

Release/Debug workaround.


Function Documentation

static int gx_globalrealloc ( void **  buffer,
int  sbuffer 
) [static]

Reallocates or frees a previously allocated memory area or allocates a new area.

Parameters:
buffer Pointer to a memory area pointer where the function receives the address of a previously allocated memory area and where it writes the address of the reallocated area. This function is also suitable for allocation if the value of *buffer is zero. If sbuffer is zero the function frees the specified memory area.
sbuffer Size of the new memory area in bytes. If it is zero it frees the area.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

Referenced by gx_globalalloc(), and gx_globalfree().

static int gx_globalalloc ( void **  buffer,
int  sbuffer 
) [static]

Allocates a memory area that can be passed between modules.

Parameters:
buffer Pointer to a memory area pointer where the function writes the address of the newly allocated area. If the original value of the pointer was non-zero the memory area will be lost after the allocation.
sbuffer Size of the memory area to allocate.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_globalrealloc().

static int gx_globalfree ( void *  buffer  )  [static]

Frees a previously allocated memory area.

Parameters:
buffer Pointer to a memory area.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_globalrealloc().

static int gx_globalsize ( int *  sbuffer,
void *  buffer 
) [static]

Gets the size of a previously allocated memory area in bytes.

Parameters:
sbuffer Pointer where the function writes the size of the area.
buffer Pointer to the memory area.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_globalrealloc_dbg ( void **  buffer,
int  sbuffer,
const char *  file,
int  line 
) [static]

Reallocates or frees a previously allocated memory area or allocates a new area (Debug version).

Parameters:
buffer Pointer to a memory area pointer where the function receives the address of a previously allocated memory area and where it writes the address of the reallocated area. This function is also suitable for allocation if the value of *buffer is zero. If sbuffer is zero the function frees the specified memory area.
sbuffer Size of the new memory area in bytes. If it is zero it frees the area.
file File name.
line Line number.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_globalalloc_dbg ( void **  buffer,
int  sbuffer,
const char *  file,
int  line 
) [static]

Allocates a memory area that can be passed between modules (Debug version).

Parameters:
buffer Pointer to a memory area pointer where the function writes the address of the newly allocated area. If the original value of the pointer was non-zero the memory area will be lost after the allocation.
sbuffer Size of the memory area to allocate.
file File name.
line Line number.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_globalrealloc_dbg.

static int gx_globalcheck_dbg (  )  [static]

Checks the memory consistency previously allocated with the gx_globalalloc() or gx_globalrealloc() functions (Debug version).

Returns:
On memory inconsistency error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_globaltestmem_dbg ( int  index,
char *  fnbuffer,
int  fnbsize,
char *  membuffer,
int  mbsize,
int *  line,
int *  size,
void **  address 
) [static]

Returns details about the unfreed memory previously allocated with the gx_globalalloc() or gx_globalrealloc() functions (Debug version).

Parameters:
index The index of the allocated memory (global).
fnbuffer Preallocated buffer for returning the file name where the allocation happened.
fnbsize The size of the preallocated file name buffer.
membuffer Preallocated buffer for returning the memory content (human readable format).
mbsize The size of the preallocated memory content buffer.
line The line number where the allocation happened.
size The size of the allocated memory area.
address Pointer for returning the allocate memory address.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_creatememslot ( int *  handle,
void **  mem 
) [static]

Allocates a memory slot and returns a handle to it.

Note:
The reference counter is set to 1.
Parameters:
handle Preallocated buffer for the result.
mem Preallocated buffer for getting the memslot address.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_getmemslot ( int  handle,
void **  mem 
) [static]

Returns the memory pointer to use on data update.

Parameters:
handle The handle of the memslot.
mem Preallocated buffer for the result.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_unrefmemslot ( int  handle  )  [static]

Decrements the memory slot's reference counter.

Note:
If the reference counter becames 0 the memory slot is deleted.
Parameters:
handle The handle of the memslot.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().


Generated  for GX
(c) Adaptive Recognition