Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
alloc.h File Reference

Test intern memory managment. More...

#include <stddef.h>
#include "internal/common.h"

Go to the source code of this file.

Functions

CR_BEGIN_C_API CR_API void * cr_malloc (size_t size)
 
CR_API void * cr_calloc (size_t nmemb, size_t size)
 
CR_API void * cr_realloc (void *ptr, size_t size)
 
CR_API void cr_free (void *ptr)
 

Detailed Description

Test intern memory managment.

Definition in file alloc.h.

Function Documentation

◆ cr_calloc()

CR_API void * cr_calloc ( size_t nmemb,
size_t size )

Allocates and zero-initialize a block of memory usable by the test.

It is undefined behaviour to access a pointer returned by calloc(3) inside a test or its setup and teardown functions; cr_calloc must be use in its place for this purpose.

This function is semantically identical to calloc(3).

Parameters
[in]nmembThe number of elements to allocate
[in]sizeThe minimal size of each element.
Returns
The pointer to the start of the allocated memory.

◆ cr_free()

CR_API void cr_free ( void * ptr)

Free a block of memory allocated by cr_malloc, cr_free or cr_realloc.

Parameters
[in]ptrA pointer to the memory that needs to be freed.

◆ cr_malloc()

CR_BEGIN_C_API CR_API void * cr_malloc ( size_t size)

Allocates a block of memory usable by the test.

It is undefined behaviour to access a pointer returned by malloc(3) inside a test or its setup and teardown functions; cr_malloc must be use in its place for this purpose.

This function is semantically identical to malloc(3).

Parameters
[in]sizeThe minimal size in bytes of the newly allocated memory.
Returns
The pointer to the start of the allocated memory.

◆ cr_realloc()

CR_API void * cr_realloc ( void * ptr,
size_t size )

Reallocates a block of memory usable by the test.

It is undefined behaviour to access a pointer returned by realloc(3) inside a test or its setup and teardown functions; cr_realloc must be used in its place for this purpose.

This function is semantically identical to realloc(3).

Parameters
[in]ptrA pointer to the memory that needs to be resized.
[in]sizeThe minimal size of the reallocated memory.
Returns
The pointer to the start of the reallocated memory.