Browse Source

remove unused array type TYPE_COUNT data_count

(unused type, and very similar to TYPE_INTEGER data_integer,
 differing only in initial value and how dup inserts are merged)
personal/stbuehler/mod-csrf-old
Glenn Strauss 5 years ago
parent
commit
381aaae363
  1. 2
      src/CMakeLists.txt
  2. 2
      src/Makefile.am
  3. 2
      src/SConscript
  4. 12
      src/array.c
  5. 10
      src/array.h
  6. 71
      src/data_count.c
  7. 1
      src/mod_magnet.c

2
src/CMakeLists.txt

@ -500,7 +500,7 @@ set(COMMON_SRC
keyvalue.c chunk.c
http_chunk.c stream.c fdevent.c
stat_cache.c plugin.c joblist.c etag.c array.c
data_string.c data_count.c data_array.c
data_string.c data_array.c
data_integer.c md5.c data_fastcgi.c
vector.c
fdevent_select.c fdevent_libev.c

2
src/Makefile.am

@ -65,7 +65,7 @@ common_src=base64.c buffer.c log.c \
keyvalue.c chunk.c \
http_chunk.c stream.c fdevent.c \
stat_cache.c plugin.c joblist.c etag.c array.c \
data_string.c data_count.c data_array.c \
data_string.c data_array.c \
data_integer.c md5.c data_fastcgi.c \
vector.c \
fdevent_select.c fdevent_libev.c \

2
src/SConscript

@ -42,7 +42,7 @@ common_src = Split("base64.c buffer.c log.c \
keyvalue.c chunk.c \
http_chunk.c stream.c fdevent.c \
stat_cache.c plugin.c joblist.c etag.c array.c \
data_string.c data_count.c data_array.c \
data_string.c data_array.c \
data_integer.c md5.c data_fastcgi.c \
vector.c \
fdevent_select.c fdevent_libev.c \

12
src/array.c

@ -324,7 +324,6 @@ int array_print(array *a, int depth) {
switch (du->type) {
case TYPE_INTEGER:
case TYPE_STRING:
case TYPE_COUNT:
break;
default:
oneline = 0;
@ -379,7 +378,6 @@ int array_print(array *a, int depth) {
int main (int argc, char **argv) {
array *a;
data_string *ds;
data_count *dc;
UNUSED(argc);
UNUSED(argv);
@ -404,16 +402,6 @@ int main (int argc, char **argv) {
array_insert_unique(a, (data_unset *)ds);
dc = data_count_init();
buffer_copy_string_len(dc->key, CONST_STR_LEN("def"));
array_insert_unique(a, (data_unset *)dc);
dc = data_count_init();
buffer_copy_string_len(dc->key, CONST_STR_LEN("def"));
array_insert_unique(a, (data_unset *)dc);
array_print(a, 0);
array_free(a);

10
src/array.h

@ -13,7 +13,7 @@
#define DATA_IS_STRING(x) (x->type == TYPE_STRING)
typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_COUNT, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_OTHER, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
#define DATA_UNSET \
data_type_t type; \
buffer *key; \
@ -39,14 +39,6 @@ typedef struct {
size_t unique_ndx;
} array;
typedef struct {
DATA_UNSET;
int count;
} data_count;
data_count *data_count_init(void);
typedef struct {
DATA_UNSET;

71
src/data_count.c

@ -1,71 +0,0 @@
#include "first.h"
#include "array.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
static data_unset *data_count_copy(const data_unset *s) {
data_count *src = (data_count *)s;
data_count *ds = data_count_init();
buffer_copy_buffer(ds->key, src->key);
ds->count = src->count;
ds->is_index_key = src->is_index_key;
return (data_unset *)ds;
}
static void data_count_free(data_unset *d) {
data_count *ds = (data_count *)d;
buffer_free(ds->key);
free(d);
}
static void data_count_reset(data_unset *d) {
data_count *ds = (data_count *)d;
buffer_reset(ds->key);
ds->count = 0;
}
static int data_count_insert_dup(data_unset *dst, data_unset *src) {
data_count *ds_dst = (data_count *)dst;
data_count *ds_src = (data_count *)src;
ds_dst->count += ds_src->count;
src->free(src);
return 0;
}
static void data_count_print(const data_unset *d, int depth) {
data_count *ds = (data_count *)d;
UNUSED(depth);
fprintf(stdout, "count(%d)", ds->count);
}
data_count *data_count_init(void) {
data_count *ds;
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->count = 1;
ds->copy = data_count_copy;
ds->free = data_count_free;
ds->reset = data_count_reset;
ds->insert_dup = data_count_insert_dup;
ds->print = data_count_print;
ds->type = TYPE_COUNT;
return ds;
}

1
src/mod_magnet.c

@ -239,7 +239,6 @@ static int magnet_array_next(lua_State *L) {
lua_pushnil(L);
}
break;
case TYPE_COUNT:
case TYPE_INTEGER:
di = (data_integer *)du;
lua_pushinteger(L, di->value);

Loading…
Cancel
Save