libnds
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
dynamicArray.h File Reference

A dynamically resizing array for general use. More...

#include <stdlib.h>
#include <string.h>
#include <nds/ndstypes.h>

Data Structures

struct  DynamicArray
 A resizable array. More...
 

Typedefs

typedef struct DynamicArray DynamicArray
 A resizable array.
 

Functions

void DynamicArrayDelete (DynamicArray *v)
 Frees memory allocated by the dynamic array.
 
void * DynamicArrayGet (DynamicArray *v, unsigned int index)
 Gets the entry at the supplied index.
 
void * DynamicArrayInit (DynamicArray *v, unsigned int initialSize)
 Initializes an array with the supplied initial size.
 
bool DynamicArraySet (DynamicArray *v, unsigned int index, void *item)
 Sets the entry to the supplied value.
 

Detailed Description

A dynamically resizing array for general use.

Function Documentation

◆ DynamicArrayDelete()

void DynamicArrayDelete ( DynamicArray v)

Frees memory allocated by the dynamic array.

Parameters
vThe array to delete

◆ DynamicArrayGet()

void * DynamicArrayGet ( DynamicArray v,
unsigned int  index 
)

Gets the entry at the supplied index.

Parameters
vThe array to get from.
indexThe index of the data to get.
Returns
The data or NULL if v is NULL or the index is out of range.

◆ DynamicArrayInit()

void * DynamicArrayInit ( DynamicArray v,
unsigned int  initialSize 
)

Initializes an array with the supplied initial size.

Parameters
vThe array to initialize.
initialSizeThe initial size to allocate.
Returns
A pointer to the data, or NULL on error.

◆ DynamicArraySet()

bool DynamicArraySet ( DynamicArray v,
unsigned int  index,
void *  item 
)

Sets the entry to the supplied value.

Parameters
vThe array to set
indexThe index of the data to set (array will be resized to fit the index).
itemThe data to set.
Returns
Returns false if v is NULL or there isn't enough memory, true otherwise.