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

Create and destroy dynamic arrays. More...

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

Go to the source code of this file.

Functions

array_t array_new (size_t type_size)
 Contructs an empty array, no memory is allocated.
void array_clear (array_t *self)
 Clears properly the array.
void array_clear_f (array_t *self, void(*cleanup)(void *))
 Release the resources of each elements before clearing the array.

Detailed Description

Create and destroy dynamic arrays.

Author
Antoine GAGNIERE

Definition in file constructors_destructors.c.

Function Documentation

◆ array_clear()

void array_clear ( array_t * self)

Clears properly the array.

Frees the underlying storage, and leaves the array in a usable state

Definition at line 33 of file constructors_destructors.c.

◆ array_clear_f()

void array_clear_f ( array_t * self,
void(* cleanup )(void *) )

Release the resources of each elements before clearing the array.

In the case of an array storing elements that own resources, each element should be cleaned up before the array is emptied.

Definition at line 47 of file constructors_destructors.c.