Annotation of embedaddon/lighttpd/src/data_array.c, revision 1.1.1.2
1.1.1.2 ! misho 1: #include "first.h"
! 2:
1.1 misho 3: #include "array.h"
4:
5: #include <string.h>
6: #include <stdio.h>
7: #include <stdlib.h>
8:
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();
12:
1.1.1.2 ! misho 13: buffer_copy_buffer(ds->key, src->key);
1.1 misho 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;
18: }
19:
20: static void data_array_free(data_unset *d) {
21: data_array *ds = (data_array *)d;
22:
23: buffer_free(ds->key);
24: array_free(ds->value);
25:
26: free(d);
27: }
28:
29: static void data_array_reset(data_unset *d) {
30: data_array *ds = (data_array *)d;
31:
32: /* reused array elements */
33: buffer_reset(ds->key);
34: array_reset(ds->value);
35: }
36:
37: static int data_array_insert_dup(data_unset *dst, data_unset *src) {
38: UNUSED(dst);
39:
40: src->free(src);
41:
42: return 0;
43: }
44:
45: static void data_array_print(const data_unset *d, int depth) {
46: data_array *ds = (data_array *)d;
47:
48: array_print(ds->value, depth);
49: }
50:
51: data_array *data_array_init(void) {
52: data_array *ds;
53:
54: ds = calloc(1, sizeof(*ds));
1.1.1.2 ! misho 55: force_assert(NULL != ds);
1.1 misho 56:
57: ds->key = buffer_init();
58: ds->value = array_init();
59:
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;
66:
67: return ds;
68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>