69 lines
1.3 KiB
Raw Normal View History

#include "first.h"
#include "array.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static data_unset *data_integer_copy(const data_unset *s) {
data_integer *src = (data_integer *)s;
data_integer *ds = data_integer_init();
fix buffer, chunk and http_chunk API * remove unused structs and functions (buffer_array, read_buffer) * change return type from int to void for many functions, as the return value (indicating error/success) was never checked, and the function would only fail on programming errors and not on invalid input; changed functions to use force_assert instead of returning an error. * all "len" parameters now are the real size of the memory to be read. the length of strings is given always without the terminating 0. * the "buffer" struct still counts the terminating 0 in ->used, provide buffer_string_length() to get the length of a string in a buffer. unset config "strings" have used == 0, which is used in some places to distinguish unset values from "" (empty string) values. * most buffer usages should now use it as string container. * optimise some buffer copying by "moving" data to other buffers * use (u)intmax_t for generic int-to-string functions * remove unused enum values: UNUSED_CHUNK, ENCODING_UNSET * converted BUFFER_APPEND_SLASH to inline function (no macro feature needed) * refactor: create chunkqueue_steal: moving (partial) chunks into another queue * http_chunk: added separate function to terminate chunked body instead of magic handling in http_chunk_append_mem(). http_chunk_append_* now handle empty chunks, and never terminate the chunked body. From: Stefan Bühler <> git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2015-02-08 12:37:10 +00:00
buffer_copy_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;
static void data_integer_reset(data_unset *d) {
data_integer *ds = (data_integer *)d;
/* reused integer elements */
ds->value = 0;
static int data_integer_insert_dup(data_unset *dst, data_unset *src) {
return 0;
static void data_integer_print(const data_unset *d, int depth) {
data_integer *ds = (data_integer *)d;
fprintf(stdout, "%d", ds->value);
data_integer *data_integer_init(void) {
data_integer *ds;
ds = calloc(1, sizeof(*ds));
force_assert(NULL != 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;