c-icap-doc  0.1
Modules | Macros | Typedefs | Functions

Structure which can store lists of objects. More...

Modules

 Vectors of strings
 
 Vectors of pointers
 

Macros

#define ci_vector_get(vector, i)   (i < vector->count ? (const void *)vector->items[i]: (const void *)NULL)
 Return a pointer to the i item of the vector.
 

Typedefs

typedef struct ci_vector ci_vector_t
 The ci_vector_t objects can store a list of objects. More...
 

Functions

ci_vector_tci_vector_create (size_t max_size)
 Allocate the required memory and initialize a ci_vector_t object. More...
 
void ci_vector_destroy (ci_vector_t *vector)
 Destroy an ci_vector_t object. More...
 
void * ci_vector_add (ci_vector_t *vector, const void *obj, size_t size)
 Add an item to the vector. More...
 
void ci_vector_iterate (const ci_vector_t *vector, void *data, int(*fn)(void *data, const void *))
 Run the given function for each vector item. More...
 
void * ci_vector_pop (ci_vector_t *vector)
 Delete the last element of a vector. More...
 

Detailed Description

Structure which can store lists of objects.

Typedef Documentation

The ci_vector_t objects can store a list of objects.

Currently can grow up to a fixed size.

Function Documentation

void* ci_vector_add ( ci_vector_t vector,
const void *  obj,
size_t  size 
)

Add an item to the vector.

Parameters
vectora pointer to the ci_vector_t object
objpointer to the object to add in vector
sizethe size of the new item.
Returns
a pointer to the new item on success, NULL otherwise
ci_vector_t* ci_vector_create ( size_t  max_size)

Allocate the required memory and initialize a ci_vector_t object.

Parameters
max_sizethe maximum memory to use
Returns
the allocated object on success, or NULL on failure
void ci_vector_destroy ( ci_vector_t vector)

Destroy an ci_vector_t object.

Parameters
vectora pointer to ci_vector_t object to be destroyed
void ci_vector_iterate ( const ci_vector_t vector,
void *  data,
int(*)(void *data, const void *)  fn 
)

Run the given function for each vector item.

Parameters
vectora pointer to the ci_vector_t object
dataa pointer to data which will be passed to the fn function
fna pointer to the function which will be run for each vector item. The iteration will stop if the fn function return non zero value.
void* ci_vector_pop ( ci_vector_t vector)

Delete the last element of a vector.

Parameters
vectora pointer to the ci_vector_t object
Returns
a pointer to the popped vector item on success, NULL otherwise