[MEDIUM] stick-table: make use of generic types for stored data
It's a bit cumbersome to have to know all possible storable types
from the stats interface. Instead, let's have generic types for
all data, which will facilitate their manipulation.
diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h
index 6b80eef..e702356 100644
--- a/include/proto/stick_table.h
+++ b/include/proto/stick_table.h
@@ -50,6 +50,21 @@
int stktable_get_data_type(char *name);
struct proxy *find_stktable(const char *name);
+/* return allocation size for standard data type <type> */
+static inline int stktable_type_size(int type)
+{
+ switch(type) {
+ case STD_T_SINT:
+ case STD_T_UINT:
+ return sizeof(int);
+ case STD_T_ULL:
+ return sizeof(unsigned long long);
+ case STD_T_FRQP:
+ return sizeof(struct freq_ctr_period);
+ }
+ return 0;
+}
+
/* reserve some space for data type <type>, and associate argument at <sa> if
* not NULL. Returns PE_NONE (0) if OK or an error code among :
* - PE_ENUM_OOR if <type> does not exist
@@ -85,7 +100,7 @@
break;
}
- t->data_size += stktable_data_types[type].data_length;
+ t->data_size += stktable_type_size(stktable_data_types[type].std_type);
t->data_ofs[type] = -t->data_size;
return PE_NONE;
}