}
/* Standard memory allocation functions */
-static void *malloc_std(size_t size, void *baton) {
+static void *malloc_std(void *baton, size_t size) {
(void)baton; /* Prevent compiler warnings */
return malloc(size);
}
-static void free_std(void *ptr, void *baton) {
+static void free_std(void *baton, void *ptr) {
(void)baton; /* Prevent compiler warnings */
free(ptr);
}
cb_node_t *q = ref_get_internal(p);
cbt_traverse_delete(map, q->child[0]);
cbt_traverse_delete(map, q->child[1]);
- map->free(q, map->baton);
+ map->free(map->baton, q);
} else {
- map->free(p, map->baton);
+ map->free(map->baton, p);
}
}
static cb_data_t *cbt_make_data(map_t *map, const uint8_t *str, size_t len, void *value)
{
- cb_data_t *x = map->malloc(sizeof(cb_data_t) + len, map->baton);
+ cb_data_t *x = map->malloc(map->baton, sizeof(cb_data_t) + len);
if (x != NULL) {
x->value = value;
memcpy(x->key, str, len);
c = data->key[newbyte];
newdirection = (1 + (newotherbits | c)) >> 8;
- newnode = map->malloc(sizeof(cb_node_t), map->baton);
+ newnode = map->malloc(map->baton, sizeof(cb_node_t));
if (newnode == NULL) {
return ENOMEM;
}
x = (uint8_t *)cbt_make_data(map, ubytes, ulen + 1, value);
if (x == NULL) {
- map->free(newnode, map->baton);
+ map->free(map->baton, newnode);
return ENOMEM;
}
if (strcmp(str, (const char *)data->key) != 0) {
return 1;
}
- map->free(p, map->baton);
+ map->free(map->baton, p);
if (!whereq) {
map->root = NULL;
}
*whereq = q->child[1 - direction];
- map->free(q, map->baton);
+ map->free(map->baton, q);
return 0;
}
/*! Main data structure */
typedef struct {
void *root;
- void *(*malloc)(size_t size, void *baton);
- void (*free)(void *ptr, void *baton);
+ void *(*malloc)(void *baton, size_t size);
+ void (*free)(void *baton, void *ptr);
void *baton; /*! Passed to malloc() and free() */
} map_t;