HTP  0.5
Macros | Typedefs | Functions
htp_list.h File Reference
#include "htp_core.h"
#include "bstr.h"

Go to the source code of this file.

Macros

#define htp_list_t   htp_list_array_t
 
#define htp_list_add   htp_list_array_push
 
#define htp_list_create   htp_list_array_create
 
#define htp_list_clear   htp_list_array_clear
 
#define htp_list_destroy   htp_list_array_destroy
 
#define htp_list_get   htp_list_array_get
 
#define htp_list_pop   htp_list_array_pop
 
#define htp_list_push   htp_list_array_push
 
#define htp_list_replace   htp_list_array_replace
 
#define htp_list_size   htp_list_array_size
 
#define htp_list_shift   htp_list_array_shift
 

Typedefs

typedef struct htp_list_array_t htp_list_array_t
 
typedef struct htp_list_linked_t htp_list_linked_t
 

Functions

htp_list_array_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_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)
 
htp_list_linked_thtp_list_linked_create (void)
 
void htp_list_linked_destroy (htp_list_linked_t *l)
 
int htp_list_linked_empty (const htp_list_linked_t *l)
 
void * htp_list_linked_pop (htp_list_linked_t *l)
 
htp_status_t htp_list_linked_push (htp_list_linked_t *l, void *e)
 
void * htp_list_linked_shift (htp_list_linked_t *l)
 

Detailed Description

Author
Ivan Ristic ivanr.nosp@m.@web.nosp@m.kreat.nosp@m.or.c.nosp@m.om

Macro Definition Documentation

#define htp_list_add   htp_list_array_push
#define htp_list_clear   htp_list_array_clear
#define htp_list_create   htp_list_array_create
#define htp_list_destroy   htp_list_array_destroy
#define htp_list_get   htp_list_array_get
#define htp_list_pop   htp_list_array_pop
#define htp_list_push   htp_list_array_push
#define htp_list_replace   htp_list_array_replace
#define htp_list_shift   htp_list_array_shift
#define htp_list_size   htp_list_array_size
#define htp_list_t   htp_list_array_t

Typedef Documentation

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_array_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.
htp_list_linked_t* htp_list_linked_create ( void  )

Create a new linked list.

Returns
The newly created list, or NULL on memory allocation failure
void htp_list_linked_destroy ( htp_list_linked_t l)

Destroy list. This function will not destroy any of the data stored in it. You'll have to do that manually beforehand.

Parameters
[in]l
int htp_list_linked_empty ( const htp_list_linked_t l)

Is the list empty?

Parameters
[in]l
Returns
1 if the list is empty, 0 if it is not
void* htp_list_linked_pop ( htp_list_linked_t l)

Remove one element from the end of the list.

Parameters
[in]l
Returns
Pointer to the removed element, or NULL if the list is empty.
htp_status_t htp_list_linked_push ( htp_list_linked_t l,
void *  e 
)

Add element to list.

Parameters
[in]l
[in]e
Returns
HTP_OK on success, HTP_ERROR on error.
void* htp_list_linked_shift ( htp_list_linked_t l)

Remove one element from the beginning of the list.

Parameters
[in]l
Returns
Pointer to the removed element, or NULL if the list is empty.