StuBS
Loading...
Searching...
No Matches
alloc.h File Reference

C-style dynamic memory allocation interface. More...

#include "types.h"
Include dependency graph for alloc.h:
This graph shows which files directly or indirectly include this file:

Functions

void * malloc (size_t size)
 Allocate a memory block The memory is not initialized.
 
void free (void *ptr)
 Free an allocated memory block.
 
void * calloc (size_t nmemb, size_t size)
 Allocate memory for an array of elements The memory is set to zero.
 

Detailed Description

C-style dynamic memory allocation interface.

Function Documentation

◆ calloc()

void * calloc ( size_t nmemb,
size_t size )

Allocate memory for an array of elements The memory is set to zero.

Parameters
nmembNumber of elements
sizeSize of an element in bytes
Returns
pointer to the allocated memory or nullptr if the request fails
Optional
Implement method

◆ free()

void free ( void * ptr)

Free an allocated memory block.

Parameters
ptrPointer to an previously allocated memory block.
Optional
Implement method

◆ malloc()

void * malloc ( size_t size)

Allocate a memory block The memory is not initialized.

Parameters
sizeRequested size of memory in bytes.
Returns
Pointer to memory or nullptr on error (no memory available) or if size was zero.
Optional
Implement method