Annotation of embedaddon/lighttpd/src/data_count.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_count_copy(const data_unset *s) {
10: data_count *src = (data_count *)s;
11: data_count *ds = data_count_init();
12:
1.1.1.2 ! misho 13: buffer_copy_buffer(ds->key, src->key);
1.1 misho 14: ds->count = src->count;
15: ds->is_index_key = src->is_index_key;
16: return (data_unset *)ds;
17: }
18:
19: static void data_count_free(data_unset *d) {
20: data_count *ds = (data_count *)d;
21:
22: buffer_free(ds->key);
23:
24: free(d);
25: }
26:
27: static void data_count_reset(data_unset *d) {
28: data_count *ds = (data_count *)d;
29:
30: buffer_reset(ds->key);
31:
32: ds->count = 0;
33: }
34:
35: static int data_count_insert_dup(data_unset *dst, data_unset *src) {
36: data_count *ds_dst = (data_count *)dst;
37: data_count *ds_src = (data_count *)src;
38:
39: ds_dst->count += ds_src->count;
40:
41: src->free(src);
42:
43: return 0;
44: }
45:
46: static void data_count_print(const data_unset *d, int depth) {
47: data_count *ds = (data_count *)d;
48: UNUSED(depth);
49:
50: fprintf(stdout, "count(%d)", ds->count);
51: }
52:
53:
54: data_count *data_count_init(void) {
55: data_count *ds;
56:
57: ds = calloc(1, sizeof(*ds));
1.1.1.2 ! misho 58: force_assert(NULL != ds);
1.1 misho 59:
60: ds->key = buffer_init();
61: ds->count = 1;
62:
63: ds->copy = data_count_copy;
64: ds->free = data_count_free;
65: ds->reset = data_count_reset;
66: ds->insert_dup = data_count_insert_dup;
67: ds->print = data_count_print;
68: ds->type = TYPE_COUNT;
69:
70: return ds;
71: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>