WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

Array helper.
[Data Structure.]

Functions

void pj_array_insert (void *array, unsigned elem_size, unsigned count, unsigned pos, const void *value)
void pj_array_erase (void *array, unsigned elem_size, unsigned count, unsigned pos)
pj_status_t pj_array_find (const void *array, unsigned elem_size, unsigned count, pj_status_t(*matching)(const void *value), void **result)

Detailed Description

This module provides helper to manipulate array of elements of any size. It provides most used array operations such as insert, erase, and search.


Function Documentation

void pj_array_erase ( void *  array,
unsigned  elem_size,
unsigned  count,
unsigned  pos 
)

Erase a value from the array at given position, and rearrange the remaining elements post the erased element.

Parameters:
array the array.
elem_size the size of the individual element.
count the current number of elements in the array.
pos the index/position to delete.
pj_status_t pj_array_find ( const void *  array,
unsigned  elem_size,
unsigned  count,
pj_status_t(*)(const void *value)  matching,
void **  result 
)

Search the first value in the array according to matching function.

Parameters:
array the array.
elem_size the individual size of the element.
count the number of elements.
matching the matching function, which MUST return PJ_SUCCESS if the specified element match.
result the pointer to the value found.
Returns:
PJ_SUCCESS if value is found, otherwise the error code.
void pj_array_insert ( void *  array,
unsigned  elem_size,
unsigned  count,
unsigned  pos,
const void *  value 
)

Insert value to the array at the given position, and rearrange the remaining nodes after the position.

Parameters:
array the array.
elem_size the size of the individual element.
count the CURRENT number of elements in the array.
pos the position where the new element is put.
value the value to copy to the new element.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.