blob: 96d1d0afe8a5bdd073afb97f7929e8cefb7428bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "array.h"
static data_unset *data_integer_copy(const data_unset *s) {
data_integer *src = (data_integer *)s;
data_integer *ds = data_integer_init();
buffer_copy_string_buffer(ds->key, src->key);
ds->is_index_key = src->is_index_key;
ds->value = src->value;
return (data_unset *)ds;
}
static void data_integer_free(data_unset *d) {
data_integer *ds = (data_integer *)d;
buffer_free(ds->key);
free(d);
}
static void data_integer_reset(data_unset *d) {
data_integer *ds = (data_integer *)d;
/* reused integer elements */
buffer_reset(ds->key);
ds->value = 0;
}
static int data_integer_insert_dup(data_unset *dst, data_unset *src) {
UNUSED(dst);
src->free(src);
return 0;
}
static void data_integer_print(const data_unset *d, int depth) {
data_integer *ds = (data_integer *)d;
UNUSED(depth);
fprintf(stderr, "%d", ds->value);
}
data_integer *data_integer_init(void) {
data_integer *ds;
ds = calloc(1, sizeof(*ds));
ds->key = buffer_init();
ds->value = 0;
ds->copy = data_integer_copy;
ds->free = data_integer_free;
ds->reset = data_integer_reset;
ds->insert_dup = data_integer_insert_dup;
ds->print = data_integer_print;
ds->type = TYPE_INTEGER;
return ds;
}
|