@@ -17,6 +17,8 @@
/* Field name/descriptor for number of hits */
#define TRACEEVAL_VAL_HITS ((const char *)(-1UL))
+#define TRACEEVAL_ARRAY_SIZE(data) (sizeof(data) / sizeof((data)[0]))
+
/* Data type distinguishers */
enum traceeval_data_type {
TRACEEVAL_TYPE_NONE,
@@ -186,15 +188,22 @@ struct traceeval *traceeval_init(struct traceeval_type *keys,
void traceeval_release(struct traceeval *teval);
-int traceeval_insert(struct traceeval *teval,
- const struct traceeval_data *keys,
- const struct traceeval_data *vals);
+int traceeval_insert_size(struct traceeval *teval,
+ const struct traceeval_data *keys, size_t nr_keys,
+ const struct traceeval_data *vals, size_t nr_vals);
+
+#define traceeval_insert(teval, keys, vals) \
+ traceeval_insert_size(teval, keys, TRACEEVAL_ARRAY_SIZE(keys), \
+ vals, TRACEEVAL_ARRAY_SIZE(vals))
int traceeval_remove(struct traceeval *teval,
const struct traceeval_data *keys);
-int traceeval_query(struct traceeval *teval, const struct traceeval_data *keys,
- const struct traceeval_data **results);
+int traceeval_query_size(struct traceeval *teval, const struct traceeval_data *keys,
+ size_t nr_keys, const struct traceeval_data **results);
+
+#define traceeval_query(teval, keys, results) \
+ traceeval_query_size(teval, keys, TRACEEVAL_ARRAY_SIZE(keys), results)
void traceeval_results_release(struct traceeval *teval,
const struct traceeval_data *results);
@@ -675,8 +675,8 @@ fail:
*
* Returns 1 if found, 0 if not found, and -1 on error.
*/
-int traceeval_query(struct traceeval *teval, const struct traceeval_data *keys,
- const struct traceeval_data **results)
+int traceeval_query_size(struct traceeval *teval, const struct traceeval_data *keys,
+ size_t nr_keys, const struct traceeval_data **results)
{
struct entry *entry;
int check;
@@ -684,6 +684,9 @@ int traceeval_query(struct traceeval *teval, const struct traceeval_data *keys,
if (!teval || !keys || !results)
return -1;
+ if (nr_keys != teval->nr_key_types)
+ return -1;
+
/* find key and copy its corresponding value pair */
if ((check = get_entry(teval, keys, &entry)) < 1)
return check;
@@ -933,14 +936,17 @@ unsigned long long traceeval_stat_count(struct traceeval_stat *stat)
*
* Returns 0 on success, and -1 on error.
*/
-int traceeval_insert(struct traceeval *teval,
- const struct traceeval_data *keys,
- const struct traceeval_data *vals)
+int traceeval_insert_size(struct traceeval *teval,
+ const struct traceeval_data *keys, size_t nr_keys,
+ const struct traceeval_data *vals, size_t nr_vals)
{
struct entry *entry;
int check;
int i;
+ if (nr_keys != teval->nr_key_types || nr_vals != teval->nr_val_types)
+ return -1;
+
entry = NULL;
check = get_entry(teval, keys, &entry);