O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
memory.c File Reference

Modify the underlying storage of an array. More...

#include "private.h"
#include "o2s/array.h"
#include <stdlib.h>

Go to the source code of this file.

Functions

size_t array_offset (const array_t *self, size_t count)
 The size in memory of count elements.
bool array_reserve (array_t *self, size_t count)
 Ensures the array has enough capacity to fit count new elements, reallocating if needed.
bool array_trim (array_t *self)
 Resizes the underlying storage to fit exactly the current elements count.

Detailed Description

Modify the underlying storage of an array.

Author
Antoine GAGNIERE

Definition in file memory.c.

Function Documentation

◆ array_reserve()

bool array_reserve ( array_t * self,
size_t count )

Ensures the array has enough capacity to fit count new elements, reallocating if needed.

Returns
false if allocation was needed and failed.

Definition at line 47 of file memory.c.

◆ array_trim()

bool array_trim ( array_t * self)

Resizes the underlying storage to fit exactly the current elements count.

Returns
false if allocation failed.

Definition at line 65 of file memory.c.