Libical API Documentation 3.0
|
An array of arbitrarily-sized elements which grows dynamically as elements are added. More...
Go to the source code of this file.
Data Structures | |
struct | _icalarray |
Typedefs | |
typedef struct _icalarray | icalarray |
A struct representing an icalarray object. | |
Functions | |
void | icalarray_append (icalarray *array, const void *element) |
Appends an element to an array. | |
icalarray * | icalarray_copy (icalarray *array) |
Copies an existing icalarray and its elements, creating a new one. | |
void * | icalarray_element_at (icalarray *array, size_t position) |
Access an array element. | |
void | icalarray_free (icalarray *array) |
Frees an array object and everything that it contains. | |
icalarray * | icalarray_new (size_t element_size, size_t increment_size) |
Creates a new icalarray object. | |
void | icalarray_remove_element_at (icalarray *array, size_t position) |
Removes a given element from an array. | |
void | icalarray_sort (icalarray *array, int(*compare)(const void *, const void *)) |
Sorts the elements of an icalarray using the given comparison function. | |
An array of arbitrarily-sized elements which grows dynamically as elements are added.
void icalarray_append | ( | icalarray * | array, |
const void * | element | ||
) |
Appends an element to an array.
array | The array to append the element to |
element | The element to append |
Appends the given element to the array, reallocating and expanding the array as needed.
NULL
, using this function results in undefined behaviour (most likely a segfault).Copies an existing icalarray and its elements, creating a new one.
array | The array to copy |
Creates a new icalarray object, copying all the existing elements from array as well as its properties (such as element_size and increment_size) over.
NULL
, this method will return NULL
. If there was an error allocating memory while creating the copy, it will set icalerrno to ICAL_ALLOCATION_ERROR.void * icalarray_element_at | ( | icalarray * | array, |
size_t | position | ||
) |
Access an array element.
array | The array object in which the element is stored |
position | The position of the element to access in the array |
Accesses an array element by returning a pointer to it, given an array and a valid element position.
NULL
, using this function results in undefined behaviour. If position is not a valid position in the array, using this function results in undefined behaviour.void icalarray_free | ( | icalarray * | array | ) |
Frees an array object and everything that it contains.
array | The array to release |
icalarray * icalarray_new | ( | size_t | element_size, |
size_t | increment_size | ||
) |
Creates a new icalarray object.
element_size | The size of the elements to be held by the array |
increment_size | How many extra elements worth of space to allocate on expansion |
Creates a new icalarray object. The parameter element_size determines the size of the elements that the array will hold (in bytes). The parameter increment_size determines how many extra elements to be allocated when expanding the array for performance reasons (expansions are expensive, since it involves copying all existing elements).
NULL
and sets icalerrno to ICAL_NEWFAILED_ERROR.void icalarray_remove_element_at | ( | icalarray * | array, |
size_t | position | ||
) |
Removes a given element from an array.
array | The array from which to remove the element |
position | The position of the element to remove |
Removes the element at the given position from the array.
NULL
, using this function results in undefined behaviour. If the array is empty, using this function results in undefined behaviour. If the position is non-existent, it removes the last element.void icalarray_sort | ( | icalarray * | array, |
int(*)(const void *, const void *) | compare | ||
) |
Sorts the elements of an icalarray using the given comparison function.
array | The array to sort |
compare | The comparison function to use |
NULL
as either array or compare results in undefined behaviour.