Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
Memory Allocation

Memory allocation utilities. More...

Functions

void * ft_calloc (size_t count, size_t size)
 Allocates and zeroes memory for an array.
bool ft_realloc (char **buff, size_t cap, size_t newcap)
 Reallocates a buffer to a new capacity.

Detailed Description

Memory allocation utilities.

Functions for allocating and reallocating memory.

Function Documentation

◆ ft_calloc()

void * ft_calloc ( size_t count,
size_t size )

Allocates and zeroes memory for an array.

Note
Caller owns the returned memory and must free it.
Parameters
countNumber of elements.
sizeSize of each element.
Returns
Pointer to allocated zeroed memory (owned), or NULL on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ft_realloc()

bool ft_realloc ( char ** buff,
size_t cap,
size_t newcap )

Reallocates a buffer to a new capacity.

Note
If newcap is 0, *buff is freed and set to NULL.
Parameters
buffPointer to the buffer pointer (owned, reallocated in place).
capCurrent capacity.
newcapNew capacity (0 to free the buffer).
Returns
true on success, false on failure (original buffer unchanged).