Functions | |
| void * | cpl_xmemory_malloc (size_t size, const char *filename, int lineno) |
| Allocate memory. | |
| void * | cpl_xmemory_calloc (size_t nmemb, size_t size, const char *filename, int lineno) |
| Allocate memory. | |
| char * | cpl_xmemory_falloc (char *name, size_t offs, size_t *size, const char *srcname, int srclin) |
| Map a file's contents to memory as a char pointer. | |
| void | cpl_xmemory_fdealloc (void *ptr, size_t offs, size_t size, const char *filename, int lineno) |
| Free memory that has been allocated with falloc. | |
| void | cpl_xmemory_free (void *ptr, const char *filename, int lineno) |
| Free memory. | |
| void * | cpl_xmemory_realloc (void *ptr, size_t size, const char *filename, int lineno) |
| Re-Allocate memory. | |
| char * | cpl_xmemory_strdup (const char *s, const char *filename, int lineno) |
| Duplicate a string using calloc. | |
| void | cpl_xmemory_status (void) |
| Display memory status information. | |
| int | cpl_xmemory_is_empty (void) |
| Tell if there is still some memory allocated. | |
mmap() system call to be implemented in the local C library to function. This module has been tested on a number of current Unix * flavours and is reported to work fine. The current limitation is the limited number of pointers it can handle at the same time. | void* cpl_xmemory_calloc | ( | size_t | nmemb, | |
| size_t | size, | |||
| const char * | filename, | |||
| int | lineno | |||
| ) |
Allocate memory.
| nmemb | Number of elements to allocate. | |
| size | Size (in bytes) of each element. | |
| filename | Name of the file where the alloc took place. | |
| lineno | Line number in the file. |
cpl_xmemory_calloc(nmemb, size, __FILE__, __LINE__)
| char* cpl_xmemory_falloc | ( | char * | name, | |
| size_t | offs, | |||
| size_t * | size, | |||
| const char * | srcname, | |||
| int | srclin | |||
| ) |
Map a file's contents to memory as a char pointer.
| name | Name of the file to map | |
| offs | Offset to the first mapped byte in file. | |
| size | Returned size of the mapped file in bytes. | |
| srcname | Name of the source file making the call. | |
| srclin | Line # where the call was made. |
The offset indicates the starting point for the mapping, i.e. if you are not interested in mapping the whole file but only from a given place.
The returned pointer ptr must be deallocated with cpl_xmemory_fdealloc(ptr)
| void cpl_xmemory_fdealloc | ( | void * | ptr, | |
| size_t | offs, | |||
| size_t | size, | |||
| const char * | filename, | |||
| int | lineno | |||
| ) |
Free memory that has been allocated with falloc.
| ptr | Pointer to free. | |
| offs | Offset to the first mapped byte in file. | |
| size | size to unmap | |
| filename | Name of the file where the dealloc took place. | |
| lineno | Line number in the file. |
| void cpl_xmemory_free | ( | void * | ptr, | |
| const char * | filename, | |||
| int | lineno | |||
| ) |
Free memory.
| ptr | Pointer to free. | |
| filename | Name of the file where the dealloc took place. | |
| lineno | Line number in the file. |
| int cpl_xmemory_is_empty | ( | void | ) |
Tell if there is still some memory allocated.
| void* cpl_xmemory_malloc | ( | size_t | size, | |
| const char * | filename, | |||
| int | lineno | |||
| ) |
Allocate memory.
| size | Size (in bytes) to allocate. | |
| filename | Name of the file where the alloc took place. | |
| lineno | Line number in the file. |
cpl_xmemory_malloc(size, __FILE__, __LINE__)
| void* cpl_xmemory_realloc | ( | void * | ptr, | |
| size_t | size, | |||
| const char * | filename, | |||
| int | lineno | |||
| ) |
Re-Allocate memory.
| ptr | Pointer to free. | |
| size | Size (in bytes) to allocate. | |
| filename | Name of the file where the alloc took place. | |
| lineno | Line number in the file. |
cpl_xmemory_realloc(nmemb, size, __FILE__, __LINE__)
| void cpl_xmemory_status | ( | void | ) |
Display memory status information.
| char* cpl_xmemory_strdup | ( | const char * | s, | |
| const char * | filename, | |||
| int | lineno | |||
| ) |
Duplicate a string using calloc.
| s | String to duplicate. | |
| filename | Name of the file where the call took place. | |
| lineno | Line number in the file. |
cpl_xmemory_strdup(s, __FILE__, __LINE__)
This function calls cpl_xmemory_malloc() to do the allocation.
1.5.1