HTP 0.5
Functions
htp_list.c File Reference
#include "htp_config_auto.h"
#include "htp_private.h"

Functions

htp_status_t htp_list_array_init (htp_list_t *l, size_t size)
 
htp_list_thtp_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_release (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.nosp@m.@web.nosp@m.kreat.nosp@m.or.c.nosp@m.om

Function Documentation

◆ htp_list_array_clear()

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_array_create()

htp_list_t * htp_list_array_create ( size_t size)

Create new array-backed list.

Parameters
[in]size
Returns
Newly created list.

◆ htp_list_array_destroy()

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

◆ htp_list_array_get()

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

◆ htp_list_array_init()

htp_status_t htp_list_array_init ( htp_list_t * l,
size_t size )

◆ htp_list_array_pop()

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_list_array_push()

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_list_array_release()

void htp_list_array_release ( htp_list_array_t * l)

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

Parameters
[in]l

◆ htp_list_array_replace()

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.

◆ htp_list_array_shift()

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.

◆ htp_list_array_size()

size_t htp_list_array_size ( const htp_list_array_t * l)

Returns the size of the list.

Parameters
[in]l
Returns
List size.