StuBS
|
C-style dynamic memory allocation interface. More...
#include "types.h"
Functions | |
void * | malloc (size_t size) |
Allocate a memory block The memory is not initialized. More... | |
void | free (void *ptr) |
Free an allocated memory block. More... | |
void * | realloc (void *ptr, size_t size) |
Change the size of an allocated memory block The contents will be unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size is larger than the old size, the added memory will not be initialized. More... | |
void * | calloc (size_t nmemb, size_t size) |
Allocate memory for an array of elements The memory is set to zero. More... | |
C-style dynamic memory allocation interface.
void * malloc | ( | size_t | size | ) |
Allocate a memory block The memory is not initialized.
size | Requested size of memory in bytes. |
nullptr
on error (no memory available) or if size was zero. void free | ( | void * | ptr | ) |
Free an allocated memory block.
ptr | Pointer to an previously allocated memory block. |
void * realloc | ( | void * | ptr, |
size_t | size | ||
) |
Change the size of an allocated memory block The contents will be unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size is larger than the old size, the added memory will not be initialized.
ptr | Pointer to an previously allocated memory block. If nullptr , then the call is equivalent to malloc(). |
size | New size of the memory block. If equal to zero, then the call is equivalent to free |
nullptr
on error void * calloc | ( | size_t | nmemb, |
size_t | size | ||
) |
Allocate memory for an array of elements The memory is set to zero.
nmemb | Number of elements |
size | Size of an element in bytes |
nullptr
if the request fails