--- embedaddon/lighttpd/src/data_string.c 2014/06/15 20:20:06 1.1.1.2 +++ embedaddon/lighttpd/src/data_string.c 2016/11/02 10:35:00 1.1.1.3 @@ -1,3 +1,5 @@ +#include "first.h" + #include "array.h" #include @@ -9,8 +11,8 @@ static data_unset *data_string_copy(const data_unset * data_string *src = (data_string *)s; data_string *ds = data_string_init(); - buffer_copy_string_buffer(ds->key, src->key); - buffer_copy_string_buffer(ds->value, src->value); + buffer_copy_buffer(ds->key, src->key); + buffer_copy_buffer(ds->value, src->value); ds->is_index_key = src->is_index_key; return (data_unset *)ds; } @@ -36,11 +38,11 @@ static int data_string_insert_dup(data_unset *dst, dat data_string *ds_dst = (data_string *)dst; data_string *ds_src = (data_string *)src; - if (ds_dst->value->used) { + if (!buffer_is_empty(ds_dst->value)) { buffer_append_string_len(ds_dst->value, CONST_STR_LEN(", ")); buffer_append_string_buffer(ds_dst->value, ds_src->value); } else { - buffer_copy_string_buffer(ds_dst->value, ds_src->value); + buffer_copy_buffer(ds_dst->value, ds_src->value); } src->free(src); @@ -52,13 +54,13 @@ static int data_response_insert_dup(data_unset *dst, d data_string *ds_dst = (data_string *)dst; data_string *ds_src = (data_string *)src; - if (ds_dst->value->used) { + if (!buffer_is_empty(ds_dst->value)) { buffer_append_string_len(ds_dst->value, CONST_STR_LEN("\r\n")); buffer_append_string_buffer(ds_dst->value, ds_dst->key); buffer_append_string_len(ds_dst->value, CONST_STR_LEN(": ")); buffer_append_string_buffer(ds_dst->value, ds_src->value); } else { - buffer_copy_string_buffer(ds_dst->value, ds_src->value); + buffer_copy_buffer(ds_dst->value, ds_src->value); } src->free(src); @@ -69,18 +71,19 @@ static int data_response_insert_dup(data_unset *dst, d static void data_string_print(const data_unset *d, int depth) { data_string *ds = (data_string *)d; - unsigned int i; + size_t i, len; UNUSED(depth); /* empty and uninitialized strings */ - if (ds->value->used < 1) { + if (buffer_string_is_empty(ds->value)) { fputs("\"\"", stdout); return; } /* print out the string as is, except prepend " with backslash */ putc('"', stdout); - for (i = 0; i < ds->value->used - 1; i++) { + len = buffer_string_length(ds->value); + for (i = 0; i < len; i++) { unsigned char c = ds->value->ptr[i]; if (c == '"') { fputs("\\\"", stdout); @@ -96,7 +99,7 @@ data_string *data_string_init(void) { data_string *ds; ds = calloc(1, sizeof(*ds)); - force_assert(ds); + force_assert(NULL != ds); ds->key = buffer_init(); ds->value = buffer_init();