--- embedaddon/lighttpd/src/array.h 2013/10/14 10:32:47 1.1.1.1 +++ embedaddon/lighttpd/src/array.h 2016/11/02 10:35:00 1.1.1.2 @@ -1,15 +1,13 @@ #ifndef ARRAY_H #define ARRAY_H +#include "first.h" -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #ifdef HAVE_PCRE_H # include #endif #include "buffer.h" +#include "vector.h" #include @@ -35,13 +33,10 @@ typedef struct { size_t *sorted; - size_t used; + size_t used; /* <= SSIZE_MAX */ size_t size; size_t unique_ndx; - - size_t next_power_of_2; - int is_weakref; /* data is weakref, don't bother the data */ } array; typedef struct { @@ -105,8 +100,10 @@ typedef enum { * for compare: comp cond string/regex */ -typedef struct _data_config data_config; -struct _data_config { +typedef struct data_config data_config; +DEFINE_TYPED_VECTOR_NO_RELEASE(config_weak, data_config*); + +struct data_config { DATA_UNSET; array *value; @@ -118,7 +115,7 @@ struct _data_config { buffer *op; int context_ndx; /* more or less like an id */ - array *childs; + vector_config_weak children; /* nested */ data_config *parent; /* for chaining only */ @@ -163,13 +160,14 @@ array *array_init(void); array *array_init_array(array *a); void array_free(array *a); void array_reset(array *a); -int array_insert_unique(array *a, data_unset *str); -data_unset *array_pop(array *a); +void array_insert_unique(array *a, data_unset *entry); +data_unset *array_pop(array *a); /* only works on "simple" lists with autogenerated keys */ int array_print(array *a, int depth); data_unset *array_get_unused_element(array *a, data_type_t t); data_unset *array_get_element(array *a, const char *key); +data_unset *array_extract_element(array *a, const char *key); /* removes found entry from array */ void array_set_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len); -data_unset *array_replace(array *a, data_unset *du); +void array_replace(array *a, data_unset *entry); int array_strcasecmp(const char *a, size_t a_len, const char *b, size_t b_len); void array_print_indent(int depth); size_t array_get_max_key_length(array *a);