[core] add li_value_new_hashtable to create a GString -> liValue hashtable

personal/stbuehler/wip
Stefan Bühler 9 years ago
parent 7bc6e275ef
commit 92dc237ee8
  1. 1
      include/lighttpd/value.h
  2. 12
      src/main/value.c

@ -34,6 +34,7 @@ LI_API liValue* li_value_new_list(void);
LI_API liValue* li_value_new_hash(void);
LI_API liValue* li_value_new_action(liServer *srv, liAction *a);
LI_API liValue* li_value_new_condition(liServer *srv, liCondition *c);
LI_API GHashTable *li_value_new_hashtable(void); /* returns a GString -> liValue table with free funcs */
LI_API void li_value_list_append(liValue *list, liValue *item); /* list MUST be of type LIST */

@ -44,9 +44,7 @@ static void _value_hash_free_value(gpointer data) {
liValue* li_value_new_hash(void) {
liValue *v = g_slice_new0(liValue);
v->data.hash = g_hash_table_new_full(
(GHashFunc) g_string_hash, (GEqualFunc) g_string_equal,
_value_hash_free_key, _value_hash_free_value);
v->data.hash = li_value_new_hashtable();
v->type = LI_VALUE_HASH;
return v;
}
@ -67,6 +65,12 @@ liValue* li_value_new_condition(liServer *srv, liCondition *c) {
return v;
}
GHashTable *li_value_new_hashtable(void) {
return g_hash_table_new_full(
(GHashFunc) g_string_hash, (GEqualFunc) g_string_equal,
_value_hash_free_key, _value_hash_free_value);
}
void li_value_list_append(liValue *list, liValue *item) {
assert(LI_VALUE_LIST == list->type);
g_array_append_val(list->data.list, item);
@ -345,6 +349,8 @@ liValue* li_value_extract(liValue *val) {
}
liValue* li_value_to_key_value_list(liValue *val) {
if (NULL == val) return NULL;
if (val->type == LI_VALUE_HASH) {
GHashTable *table = li_value_extract_hash(val);
GArray *list;

Loading…
Cancel
Save