htp_list.c File Reference

#include "htp_config_auto.h"
#include "htp_private.h"

Functions

htp_list_t * htp_list_array_create (size_t size)
void htp_list_array_clear (htp_list_array_t *l)
void htp_list_array_destroy (htp_list_array_t *l)
void * htp_list_array_get (const htp_list_array_t *l, size_t idx)
void * htp_list_array_pop (htp_list_array_t *l)
htp_status_t htp_list_array_push (htp_list_array_t *l, void *e)
htp_status_t htp_list_array_replace (htp_list_array_t *l, size_t idx, void *e)
size_t htp_list_array_size (const htp_list_array_t *l)
void * htp_list_array_shift (htp_list_array_t *l)

Detailed Description

Author:
Ivan Ristic <ivanr@webkreator.com>

Function Documentation

void htp_list_array_clear ( htp_list_array_t l  ) 

Remove all elements from the list. It is the responsibility of the caller to iterate over list elements and deallocate them if necessary, prior to invoking this function.

Parameters:
[in] l 
htp_list_t* htp_list_array_create ( size_t  size  ) 

Create new array-backed list.

Parameters:
[in] size 
Returns:
Newly created list.
void htp_list_array_destroy ( htp_list_array_t l  ) 

Free the memory occupied by this list. This function assumes the elements held by the list were freed beforehand.

Parameters:
[in] l 
void* htp_list_array_get ( const htp_list_array_t l,
size_t  idx 
)

Find the element at the given index.

Parameters:
[in] l 
[in] idx 
Returns:
the desired element, or NULL if the list is too small, or if the element at that position carries a NULL
void* htp_list_array_pop ( htp_list_array_t l  ) 

Remove one element from the end of the list.

Parameters:
[in] l 
Returns:
The removed element, or NULL if the list is empty.
htp_status_t htp_list_array_push ( htp_list_array_t l,
void *  e 
)

Add new element to the end of the list, expanding the list as necessary.

Parameters:
[in] l 
[in] e 
Returns:
HTP_OK on success or HTP_ERROR on failure.
htp_status_t htp_list_array_replace ( htp_list_array_t l,
size_t  idx,
void *  e 
)

Replace the element at the given index with the provided element.

Parameters:
[in] l 
[in] idx 
[in] e 
Returns:
HTP_OK if an element with the given index was replaced; HTP_ERROR if the desired index does not exist.
void* htp_list_array_shift ( htp_list_array_t l  ) 

Remove one element from the beginning of the list.

Parameters:
[in] l 
Returns:
The removed element, or NULL if the list is empty.
size_t htp_list_array_size ( const htp_list_array_t l  ) 

Returns the size of the list.

Parameters:
[in] l 
Returns:
List size.

Generated on 1 Jan 2017 for HTP by  doxygen 1.6.1