ocssw  1.0
Classes | Functions
/disk01/web/ocssw/build/inc/meris/epr_ptrarray.h File Reference

(r8108/r7671)

#include <stdlib.h>

Go to the source code of this file.

Classes

struct  EPR_SPtrArray

Functions

EPR_SPtrArray * epr_create_ptr_array (unsigned int capacity)
void epr_free_ptr_array (EPR_SPtrArray *ptr_array)
void epr_free_char_ptr_array (EPR_SPtrArray *char_ptr_array)
int epr_add_ptr_array_elem (EPR_SPtrArray *ptr_array, void *elem)
int epr_grow_ptr_array (EPR_SPtrArray *ptr_array, unsigned int capacity)
unsigned int epr_get_ptr_array_length (const EPR_SPtrArray *ptr_array)
unsigned int epr_get_ptr_array_capacity (const EPR_SPtrArray *ptr_array)
void * epr_get_ptr_array_elem_at (const EPR_SPtrArray *ptr_array, unsigned int index)

Function Documentation

int epr_add_ptr_array_elem ( EPR_SPtrArray *  ptr_array,
void *  elem 
)

Adds a new pointer to the given pointer array. The function automatically grows the array if necessary.

Parameters:
ptr_arraythe pointer array to which to add the new element, must not be NULL.
elemthe element to be added
Returns:
zero for success, an error code otherwise

Definition at line 75 of file epr_ptrarray.c.

EPR_SPtrArray* epr_create_ptr_array ( unsigned int  capacity)

Creates a new dynamic pointer array instance.

Parameters:
capacitythe initial capacity
Returns:
a new dynamic pointer array instance with the given capacity or NULL if memory could not be allocated

Definition at line 29 of file epr_ptrarray.c.

void epr_free_char_ptr_array ( EPR_SPtrArray *  char_ptr_array)

Special application of the epr_free_ptr_array for arrays that contain dynamically allocated strings (type char*).

For each element in the given array the epr_free_string function is called.

Parameters:
char_ptr_arrayan array containing strings

Definition at line 65 of file epr_ptrarray.c.

void epr_free_ptr_array ( EPR_SPtrArray *  ptr_array)

Frees the memory allocated through the given dynamic pointer array.

After calling this function the give record pointer array gets invalid and should not be used anymore.

Parameters:
ptr_arraythe pointer array to be released, if NULL the function immediately returns

Definition at line 51 of file epr_ptrarray.c.

unsigned int epr_get_ptr_array_capacity ( const EPR_SPtrArray *  ptr_array)

Returns the capacity of the given pointer array.

Parameters:
ptr_arraythe pointer array, must not be NULL.
Returns:
the capacity of the given pointer array
void* epr_get_ptr_array_elem_at ( const EPR_SPtrArray *  ptr_array,
unsigned int  index 
)

Gets the element with the specified index of the given pointer array.

Parameters:
ptr_arraythe pointer array, must not be NULL.
indexthe zero-based index, must be less than the array's length
Returns:
the element at the given index

Definition at line 122 of file epr_ptrarray.c.

unsigned int epr_get_ptr_array_length ( const EPR_SPtrArray *  ptr_array)

Returns the length of the given pointer array.

Parameters:
ptr_arraythe pointer array, must not be NULL.
Returns:
the length of the given pointer array

Definition at line 115 of file epr_ptrarray.c.

int epr_grow_ptr_array ( EPR_SPtrArray *  ptr_array,
unsigned int  capacity 
)

Grows the given pointer array so that is has the given capacity. The length of the array is not touched by this function.

Parameters:
ptr_arraythe pointer array to which to add the new element, must not be NULL.
capacitythe new capacity
Returns:
zero for success, an error code otherwise

Definition at line 91 of file epr_ptrarray.c.