Annotation of embedaddon/lighttpd/src/data_integer.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 <stdio.h>
6: #include <stdlib.h>
7: #include <string.h>
8:
9: static data_unset *data_integer_copy(const data_unset *s) {
10: data_integer *src = (data_integer *)s;
11: data_integer *ds = data_integer_init();
12:
1.1.1.2 ! misho 13: buffer_copy_buffer(ds->key, src->key);
1.1 misho 14: ds->is_index_key = src->is_index_key;
15: ds->value = src->value;
16: return (data_unset *)ds;
17: }
18:
19: static void data_integer_free(data_unset *d) {
20: data_integer *ds = (data_integer *)d;
21:
22: buffer_free(ds->key);
23:
24: free(d);
25: }
26:
27: static void data_integer_reset(data_unset *d) {
28: data_integer *ds = (data_integer *)d;
29:
30: /* reused integer elements */
31: buffer_reset(ds->key);
32: ds->value = 0;
33: }
34:
35: static int data_integer_insert_dup(data_unset *dst, data_unset *src) {
36: UNUSED(dst);
37:
38: src->free(src);
39:
40: return 0;
41: }
42:
43: static void data_integer_print(const data_unset *d, int depth) {
44: data_integer *ds = (data_integer *)d;
45: UNUSED(depth);
46:
47: fprintf(stdout, "%d", ds->value);
48: }
49:
50:
51: data_integer *data_integer_init(void) {
52: data_integer *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 = 0;
59:
60: ds->copy = data_integer_copy;
61: ds->free = data_integer_free;
62: ds->reset = data_integer_reset;
63: ds->insert_dup = data_integer_insert_dup;
64: ds->print = data_integer_print;
65: ds->type = TYPE_INTEGER;
66:
67: return ds;
68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>