Main Page | Modules | Alphabetical List | Class List | Directories | Class Members

Memory Management Utilities


Functions

void * cpl_malloc (size_t nbytes)
 Allocate nbytes bytes.
void * cpl_calloc (size_t natoms, size_t nbytes)
 Allocate memory for natoms elements of size size.
void * cpl_realloc (void *memblk, size_t nbytes)
 Change the size of a memory block.
void cpl_free (void *memblk)
 Memory block deallocation.
char * cpl_strdup (const char *string)
 Duplicate a string.

Detailed Description

This module provides the CPL memory management utilities. CPL uses its own memory management system in order to provide almost infinite virtual memory (only limited by the file system size). However, this functionality has certain restrictions. Memory which was allocated using one of the CPL allocator functions must be released with the CPL deallocator function. The same applies to memory blocks allocated and returned by CPL functions. The CPL memory management subsystem uses the services provided by qfits' xmemory module.

Function Documentation

void* cpl_calloc size_t  natoms,
size_t  nbytes
 

Allocate memory for natoms elements of size size.

Parameters:
natoms Number of atomic elements.
nbytes Element size in bytes.
Returns:
Pointer to the allocated memory block.
The function allocates memory suitable for storage of natoms elements of size nbytes bytes. The allocated memory is cleared, i.e. the value 0 is written to each single byte.

Note:
If the memory subsytem has not been initialised before calling this function, the program execution is stopped printing a message to the error channel showing the current code position.

void cpl_free void *  memblk  ) 
 

Memory block deallocation.

Returns:
Nothing.
Deallocates a memory block previously allocated by any of the CPL allocator functions.

See also:
cpl_malloc(), cpl_calloc()

void* cpl_malloc size_t  nbytes  ) 
 

Allocate nbytes bytes.

Parameters:
nbytes Number of bytes.
Returns:
Pointer to the allocated memory block.
The function allocates nbytes bytes of memory. The allocated memory is not cleared.

Note:
If the memory subsytem has not been initialised before calling this function, the program execution is stopped printing a message to the error channel showing the current code position.

void* cpl_realloc void *  memblk,
size_t  nbytes
 

Change the size of a memory block.

Parameters:
memblk Number of atomic elements.
nbytes New memory block size in bytes.
Returns:
Pointer to the allocated memory block.
The function changes the size of an already allocated memory block memblk to the new size nbytes bytes. The contents is unchanged to the minimum of old and new size; newly allocated memory is not initialized. If memblk is NULL the call to cpl_realloc() is equivalent to cpl_malloc(), and if nbytes is 0 the call is equivalent to cpl_free(). Unless memblk is NULL, it must have been returned by a previous call to cpl_malloc(), cpl_calloc(), or cpl_realloc().

Note:
  • The returned memory block returned on successfull allocation may not be the same as the one pointed to by memblk. Existing references pointing to locations within the original memory block might be invalidated!
  • If the memory subsytem has not been initialised before calling this function, the program execution is stopped printing a message to the error channel showing the current code position.
See also:
cpl_malloc(), cpl_calloc()

char* cpl_strdup const char *  string  ) 
 

Duplicate a string.

Parameters:
string String to be duplicated.
Returns:
Newly allocated copy of the original string.
Duplicates the input string string. The newly allocated copy returned to the caller can be deallocated using cpl_free().

See also:
cpl_free()


Generated on Mon Sep 26 14:38:17 2005 for Common Pipeline Library Reference Manual by  doxygen 1.4.1