libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches
CMUTIL_Mem Struct Reference

#include <libcmutils.h>

Data Fields

void *(* Alloc )(size_t size)
 Allocate memory.
 
void *(* Calloc )(size_t nmem, size_t size)
 Allocate memory with zero filled.
 
void *(* Realloc )(void *ptr, size_t size)
 Reallocate memory.
 
char *(* Strdup )(const char *str)
 Duplicate a string.
 
void(* Free )(void *ptr)
 Free memory.
 

Detailed Description

Memory operation interface.

Field Documentation

◆ Alloc

void *(* CMUTIL_Mem::Alloc) (size_t size)

Allocate memory.

Allocates size bytes and returns a pointer to the allocated memory. The memory is not initialized. If size is 0, then this function returns either NULL or a unique pointer value that can later be successfully passed to Free.

Parameters
sizeCount of bytes to be allocated.
Returns
A pointer to the allocated memory, which is suitably aligned for any built-in type. On error this function returns NULL. NULL may also be returned by a successful call to this function with a size of zero.

◆ Calloc

void *(* CMUTIL_Mem::Calloc) (size_t nmem, size_t size)

Allocate memory with zero filled.

Parameters
nmemCount of memory elements to be allocated.
sizeSize of each memory element.
Returns
A pointer to the allocated memory, which is suitably aligned for any built-in type. On error this function returns NULL. NULL may also be returned by a successful call to this function with a size of zero.

◆ Realloc

void *(* CMUTIL_Mem::Realloc) (void *ptr, size_t size)

Reallocate memory.

Parameters
ptrPointer to the memory block to be reallocated.
sizeNew size of the memory block.
Returns
A pointer to the reallocated memory, which is suitably aligned for any built-in type. On error this function returns NULL. NULL may also be returned by a successful call to this function with a size of zero.

◆ Strdup

char *(* CMUTIL_Mem::Strdup) (const char *str)

Duplicate a string.

Parameters
strPointer to the string to be duplicated.
Returns
A pointer to the duplicated string, which is suitably aligned for any built-in type. On error this function returns NULL. NULL may also be returned by a successful call to this function with a str of NULL.

◆ Free

void(* CMUTIL_Mem::Free) (void *ptr)

Free memory.

Parameters
ptrPointer to the memory block to be freed.

The documentation for this struct was generated from the following file: