Macros | |
#define | IL_MALLOC(type, n) |
Allocates an array of objects. More... | |
#define | IL_REALLOC(type, array, n) |
Re-allocates an array of objects. More... | |
#define | IL_STRCASECMP(s1, s2) |
Compares two strings in a case-insensitive manner. More... | |
#define | IL_STRNCASECMP(s1, s2, n) |
Compares two strings in a case-insensitive manner. More... | |
Functions | |
char * | IlCopyString (const char *string, IlBoolean zeroIfEmpty=IlTrue) |
Allocates and returns a copy of a string. More... | |
void | IlFree (void *block) |
Deallocation routine. More... | |
void * | IlMalloc (std::size_t nBytes) |
Allocation routine. More... | |
void * | IlMemMove (void *destination, const void *source, std::size_t size) |
Allocation routine. More... | |
void * | IlRealloc (void *block, std::size_t size) |
Re-allocation routine. More... | |
Library: ilog
Declaration of common memory management routines and macros used in Rogue Wave visualization products.
#define IL_MALLOC | ( | type, | |
n | |||
) |
Allocates an array of objects.
The allocation is perfomed using IlMalloc()
that is invoked with a total size of n * sizeof(
type) bytes.
Note that if type has a constructor, it is not invoked by this macro. This macro is therefore dedicated to allocated arrays of simple types.
A typical use of this macro is:
type | The object type. |
n | The number of memory slots to allocate. |
0
if this memory could not be obtained from the system.type*
and must be released by a call to IlFree()
. #define IL_REALLOC | ( | type, | |
array, | |||
n | |||
) |
Re-allocates an array of objects.
The re-allocation is perfomed using IlRealloc()
that is invoked with a total size of n * sizeof(
type) bytes.
Note that if type has a constructor, it is not invoked by this macro. This macro is therefore dedicated to allocated arrays of simple types.
A typical use of this macro is:
type | The object type. |
array | The initial array to be enlarged. |
n | The number of memory slots to allocate. |
0
if this memory could not be obtained from the system.type*
and must be released by a call to IlFree()
.IL_MALLOC()
. #define IL_STRCASECMP | ( | s1, | |
s2 | |||
) |
Compares two strings in a case-insensitive manner.
This macro provides a portable version of _stricmp()
(or strcasecmp()
). It compares two specified strings, ignoring their case, and returns an integer that indicates their relative position in the lexical order.
s1 | The first string to compare. |
s2 | The second string to compare. |
_stricmp(s1, s2)
(or the equivalent function of the target platform). #define IL_STRNCASECMP | ( | s1, | |
s2, | |||
n | |||
) |
Compares two strings in a case-insensitive manner.
This macro provides a portable version of _strnicmp()
(or strncasecmp()
). It compares two specified strings, ignoring their case, up to n characters, and returns an integer that indicates their relative position in the lexical order.
s1 | The first string to compare. |
s2 | The second string to compare. |
n | The number of characters to compare. |
_strnicmp(s1, s2, n)
(or the equivalent function of the target platform). Allocates and returns a copy of a string.
Memory for the string copy is allocated using the new []
operator, and must therefore be released using the delete []
operator.
string | The string to be copied. |
zeroIfEmpty | Indicates, if IlTrue , that 0 should be returned if the input string is empty. If zeroIfEmpty is IlFalse and string is an empty string, then a new empty string is allocated and returned. |
0
if string is 0
, or if string is empty and zeroIfEmpty is set to IlTrue
. void IlFree | ( | void * | block | ) |
Deallocation routine.
This function is a portable version of free()
. It releases a chunk of raw memory that was created by IlMalloc()
.
block | A pointer to the memory block that was obtained by IlMalloc() . |
void* IlMalloc | ( | std::size_t | nBytes | ) |
Allocation routine.
This function is a portable version of malloc()
. It allocates raw memory that must be released by IlFree()
.
Note that if this function fails to allocate storage, it invokes the C++ new-handler
function that may have been installed by a call to set_new_handler()
. If that handler function returns, a new attempt to allocate the storage is tried.
nBytes | The number of bytes to be allocated. |
0
if this memory could not be obtained from the system. void* IlMemMove | ( | void * | destination, |
const void * | source, | ||
std::size_t | size | ||
) |
Allocation routine.
This function is a portable version of memmove()
. It copies bytes from a memory location to another.
destination | The destination array where the content of source is to be copied. It must be able to store at least size consecutive bytes. |
source | The source array to be copied. It must be able to access at least size consecutive bytes. |
size | The number of bytes to be copied. |
void* IlRealloc | ( | void * | block, |
std::size_t | size | ||
) |
Re-allocation routine.
This function is a portable version of realloc()
. It re-allocates raw memory that was allocated by IlMalloc()
, and that must be released by IlFree()
. It is typically used to enlarge a previously allocated memory block.
Note that if this function fails to allocate storage, it invokes the C++ new-handler
function that may have been installed by a call to set_new_handler()
. If that handler function returns, a new attempt to allocate the storage is tried.
block | The initial memory block to be enlarged. |
size | The number of bytes to be allocated. |
0
if this memory could not be obtained from the system. This pointer can be (but does not have to be) the same as block.