[SCons] define with_krb5 for SCons build
[lighttpd.git] / src / data_array.c
blobb375276fc34843856fe7a2a70e6dd5ceb2ade87f
1 #include "first.h"
3 #include "array.h"
5 #include <string.h>
6 #include <stdio.h>
7 #include <stdlib.h>
9 static data_unset *data_array_copy(const data_unset *s) {
10 data_array *src = (data_array *)s;
11 data_array *ds = data_array_init();
13 buffer_copy_buffer(ds->key, src->key);
14 array_free(ds->value);
15 ds->value = array_init_array(src->value);
16 ds->is_index_key = src->is_index_key;
17 return (data_unset *)ds;
20 static void data_array_free(data_unset *d) {
21 data_array *ds = (data_array *)d;
23 buffer_free(ds->key);
24 array_free(ds->value);
26 free(d);
29 static void data_array_reset(data_unset *d) {
30 data_array *ds = (data_array *)d;
32 /* reused array elements */
33 buffer_reset(ds->key);
34 array_reset(ds->value);
37 static int data_array_insert_dup(data_unset *dst, data_unset *src) {
38 UNUSED(dst);
40 src->free(src);
42 return 0;
45 static void data_array_print(const data_unset *d, int depth) {
46 data_array *ds = (data_array *)d;
48 array_print(ds->value, depth);
51 data_array *data_array_init(void) {
52 data_array *ds;
54 ds = calloc(1, sizeof(*ds));
55 force_assert(NULL != ds);
57 ds->key = buffer_init();
58 ds->value = array_init();
60 ds->copy = data_array_copy;
61 ds->free = data_array_free;
62 ds->reset = data_array_reset;
63 ds->insert_dup = data_array_insert_dup;
64 ds->print = data_array_print;
65 ds->type = TYPE_ARRAY;
67 return ds;