diff --git a/examples/callbacks.c b/examples/callbacks.c new file mode 100644 index 0000000..83c6758 --- /dev/null +++ b/examples/callbacks.c @@ -0,0 +1,67 @@ +#include + +#define CMC_CALLBACKS + +#define V int +#define PFX l +#define SNAME list +#include "cmc/list.h" + +#define V int +#define PFX s +#define SNAME stack +#include "cmc/stack.h" + +#define V int +#define PFX b +#define SNAME buffer +#define SIZE 100 +#define CMC_SAC +#include "cmc/list.h" + +void callback(const char fname[], void *self) +{ + if (fname[0] == 'l') + { + struct list *l = (struct list *)self; + if (l_flag(l) != CMC_FLAG_OK) + { + printf("Error at %s: %s\n", fname, cmc_flags_to_str[l_flag(l)]); + } + } + printf("Function called: %s for collection at %p\n", fname, self); +} + +int main() +{ + struct list *l = l_new_custom(100, &(struct list_fval){}, NULL, callback); + + l_get(l, 0); /* Should error */ + + l_push_back(l, 10); + l_push_front(l, 5); + + printf("Got: %d\n", l_get(l, 1)); + + l_pop_back(l); + l_pop_back(l); + l_pop_back(l); /* Error */ + + struct stack *s = s_new_custom(100, &(struct stack_fval){}, NULL, callback); + + s_push(s, 10); + s_push(s, 5); + + printf("Got: %d\n", s_top(s)); + + struct buffer *b = b_new_custom(&(struct buffer_fval){}, NULL, callback); + + b_push_back(b, 10); + b_push_front(b, 5); + + printf("Got: %d\n", b_get(b, 1)); + + l_free(l); + s_free(s); + b_free(b); +} diff --git a/src/cmc/cmc/bitset/code.h b/src/cmc/cmc/bitset/code.h index 016e610..223c945 100644 --- a/src/cmc/cmc/bitset/code.h +++ b/src/cmc/cmc/bitset/code.h @@ -34,8 +34,7 @@ struct SNAME *CMC_(PFX, _new)(size_t n_bits) return CMC_(PFX, _new_custom)(n_bits, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -81,8 +80,7 @@ struct SNAME CMC_(PFX, _init)(size_t n_bits) return CMC_(PFX, _init_custom)(n_bits, NULL, NULL); } -struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *CMC_UNUSED(callbacks)) +struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -132,8 +130,7 @@ void CMC_(PFX, _release)(struct SNAME _bitset_) free(_bitset_.buffer); } -void CMC_(PFX, _customize)(struct SNAME *_bitset_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_bitset_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -169,7 +166,7 @@ bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, create); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -220,7 +217,7 @@ bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, create); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -243,7 +240,7 @@ bool CMC_(PFX, _clear)(struct SNAME *_bitset_, size_t bit_index) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, delete); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -294,7 +291,7 @@ bool CMC_(PFX, _clear_range)(struct SNAME *_bitset_, size_t from, size_t to) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, delete); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -317,7 +314,7 @@ bool CMC_(PFX, _flip)(struct SNAME *_bitset_, size_t bit_index) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, update); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -368,7 +365,7 @@ bool CMC_(PFX, _flip_range)(struct SNAME *_bitset_, size_t from, size_t to) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, update); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -408,7 +405,7 @@ bool CMC_(PFX, _set_all)(struct SNAME *_bitset_) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, create); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -424,7 +421,7 @@ bool CMC_(PFX, _clear_all)(struct SNAME *_bitset_) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, delete); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -440,7 +437,7 @@ bool CMC_(PFX, _flip_all)(struct SNAME *_bitset_) _bitset_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_bitset_, create); + CMC_CALLBACKS_CALL(_bitset_); return true; } @@ -507,7 +504,7 @@ bool CMC_(PFX, _impl_resize)(struct SNAME *_bitset_, size_t n_bits, bool do_resi _bitset_->capacity = words; - CMC_CALLBACKS_CALL(_bitset_, resize); + CMC_CALLBACKS_CALL(_bitset_); _bitset_->flag = CMC_FLAG_OK; diff --git a/src/cmc/cmc/bitset/header.h b/src/cmc/cmc/bitset/header.h index 9d3ab53..0144e60 100644 --- a/src/cmc/cmc/bitset/header.h +++ b/src/cmc/cmc/bitset/header.h @@ -24,15 +24,12 @@ /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t n_bits); -struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); struct SNAME CMC_(PFX, _init)(size_t n_bits); -struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _free)(struct SNAME *_bitset_); void CMC_(PFX, _release)(struct SNAME _bitset_); -void CMC_(PFX, _customize)(struct SNAME *_bitset_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_bitset_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index); bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to); diff --git a/src/cmc/cmc/bitset/struct.h b/src/cmc/cmc/bitset/struct.h index f5e7d98..a4c5857 100644 --- a/src/cmc/cmc/bitset/struct.h +++ b/src/cmc/cmc/bitset/struct.h @@ -36,7 +36,7 @@ struct SNAME /* Flags indicating errors or success */ int flag; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/deque/code.h b/src/cmc/cmc/deque/code.h index b556a0a..5c05a7e 100644 --- a/src/cmc/cmc/deque/code.h +++ b/src/cmc/cmc/deque/code.h @@ -34,8 +34,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -122,8 +122,7 @@ void CMC_(PFX, _free)(struct SNAME *_deque_) _deque_->alloc->free(_deque_); } -void CMC_(PFX, _customize)(struct SNAME *_deque_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_deque_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -160,7 +159,7 @@ bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value) _deque_->count++; _deque_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_deque_, create); + CMC_CALLBACKS_CALL(_deque_); return true; } @@ -184,7 +183,7 @@ bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value) _deque_->count++; _deque_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_deque_, create); + CMC_CALLBACKS_CALL(_deque_); return true; } @@ -208,7 +207,7 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_deque_) _deque_->count--; _deque_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_deque_, delete); + CMC_CALLBACKS_CALL(_deque_); return true; } @@ -232,7 +231,7 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_deque_) _deque_->count--; _deque_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_deque_, delete); + CMC_CALLBACKS_CALL(_deque_); return true; } @@ -251,7 +250,7 @@ V CMC_(PFX, _front)(struct SNAME *_deque_) _deque_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_deque_, read); + CMC_CALLBACKS_CALL(_deque_); return _deque_->buffer[_deque_->front]; } @@ -270,7 +269,7 @@ V CMC_(PFX, _back)(struct SNAME *_deque_) _deque_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_deque_, read); + CMC_CALLBACKS_CALL(_deque_); return _deque_->buffer[(_deque_->back == 0) ? _deque_->capacity - 1 : _deque_->back - 1]; } @@ -296,7 +295,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_deque_, V value) i = (i + 1) % _deque_->capacity; } - CMC_CALLBACKS_CALL(_deque_, read); + CMC_CALLBACKS_CALL(_deque_); return result; } @@ -387,7 +386,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_deque_, size_t capacity) success: - CMC_CALLBACKS_CALL(_deque_, resize); + CMC_CALLBACKS_CALL(_deque_); return true; } diff --git a/src/cmc/cmc/deque/ext/code.h b/src/cmc/cmc/deque/ext/code.h index f99c4b7..eaf806b 100644 --- a/src/cmc/cmc/deque/ext/code.h +++ b/src/cmc/cmc/deque/ext/code.h @@ -39,8 +39,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; diff --git a/src/cmc/cmc/deque/ext/header.h b/src/cmc/cmc/deque/ext/header.h index ce53a2b..331c620 100644 --- a/src/cmc/cmc/deque/ext/header.h +++ b/src/cmc/cmc/deque/ext/header.h @@ -31,8 +31,8 @@ #ifdef CMC_EXT_INIT struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _release)(struct SNAME _deque_); #endif /* CMC_EXT_INIT */ diff --git a/src/cmc/cmc/deque/header.h b/src/cmc/cmc/deque/header.h index 8cc168e..59976b6 100644 --- a/src/cmc/cmc/deque/header.h +++ b/src/cmc/cmc/deque/header.h @@ -41,13 +41,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_deque_); void CMC_(PFX, _free)(struct SNAME *_deque_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_deque_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_deque_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value); bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value); diff --git a/src/cmc/cmc/deque/struct.h b/src/cmc/cmc/deque/struct.h index 3515a5d..ad94cd5 100644 --- a/src/cmc/cmc/deque/struct.h +++ b/src/cmc/cmc/deque/struct.h @@ -39,7 +39,7 @@ struct SNAME /* Functions Table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/hashbidimap/code.h b/src/cmc/cmc/hashbidimap/code.h index 6664b36..283d851 100644 --- a/src/cmc/cmc/hashbidimap/code.h +++ b/src/cmc/cmc/hashbidimap/code.h @@ -43,8 +43,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY( } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -134,7 +134,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_) _map_->alloc->free(_map_); } -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -193,7 +193,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) _map_->count++; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, create); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -260,7 +260,7 @@ success: _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, update); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -328,7 +328,7 @@ success: _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, update); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -377,7 +377,7 @@ bool CMC_(PFX, _remove_by_key)(struct SNAME *_map_, K key, K *out_key, V *out_va _map_->count--; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, delete); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -426,7 +426,7 @@ bool CMC_(PFX, _remove_by_val)(struct SNAME *_map_, V val, K *out_key, V *out_va _map_->count--; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, delete); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -447,7 +447,7 @@ K CMC_(PFX, _get_key)(struct SNAME *_map_, V val) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return (*entry)->key; } @@ -468,7 +468,7 @@ V CMC_(PFX, _get_val)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return (*entry)->value; } @@ -483,7 +483,7 @@ bool CMC_(PFX, _contains_key)(struct SNAME *_map_, K key) bool result = CMC_(PFX, _impl_get_entry_by_key)(_map_, key) != NULL; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return result; } @@ -498,7 +498,7 @@ bool CMC_(PFX, _contains_val)(struct SNAME *_map_, V val) bool result = CMC_(PFX, _impl_get_entry_by_val)(_map_, val) != NULL; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return result; } @@ -649,7 +649,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity) success: - CMC_CALLBACKS_CALL(_map_, resize); + CMC_CALLBACKS_CALL(_map_); return true; } diff --git a/src/cmc/cmc/hashbidimap/ext/code.h b/src/cmc/cmc/hashbidimap/ext/code.h index 3701195..5a77dfb 100644 --- a/src/cmc/cmc/hashbidimap/ext/code.h +++ b/src/cmc/cmc/hashbidimap/ext/code.h @@ -41,8 +41,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY( } struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; diff --git a/src/cmc/cmc/hashbidimap/ext/header.h b/src/cmc/cmc/hashbidimap/ext/header.h index 2cbd29e..de02546 100644 --- a/src/cmc/cmc/hashbidimap/ext/header.h +++ b/src/cmc/cmc/hashbidimap/ext/header.h @@ -33,8 +33,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _release)(struct SNAME _map_); #endif /* CMC_EXT_INIT */ diff --git a/src/cmc/cmc/hashbidimap/header.h b/src/cmc/cmc/hashbidimap/header.h index db01c02..4758868 100644 --- a/src/cmc/cmc/hashbidimap/header.h +++ b/src/cmc/cmc/hashbidimap/header.h @@ -60,13 +60,12 @@ struct CMC_DEF_FVAL(SNAME) struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _update_key)(struct SNAME *_map_, V val, K new_key); diff --git a/src/cmc/cmc/hashbidimap/struct.h b/src/cmc/cmc/hashbidimap/struct.h index da38526..c7ca52a 100644 --- a/src/cmc/cmc/hashbidimap/struct.h +++ b/src/cmc/cmc/hashbidimap/struct.h @@ -39,7 +39,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; /* Methods */ diff --git a/src/cmc/cmc/hashmap/code.h b/src/cmc/cmc/hashmap/code.h index de71deb..b9c715e 100644 --- a/src/cmc/cmc/hashmap/code.h +++ b/src/cmc/cmc/hashmap/code.h @@ -33,8 +33,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY( } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -136,7 +136,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_) _map_->alloc->free(_map_); } -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -221,7 +221,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) _map_->count++; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, create); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -253,7 +253,7 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, update); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -289,7 +289,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) _map_->count--; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, delete); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -335,7 +335,7 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -381,7 +381,7 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -408,7 +408,7 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return entry->value; } @@ -435,7 +435,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return &(entry->value); } @@ -450,7 +450,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return result; } @@ -587,7 +587,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity) success: - CMC_CALLBACKS_CALL(_map_, resize); + CMC_CALLBACKS_CALL(_map_); return true; } diff --git a/src/cmc/cmc/hashmap/ext/code.h b/src/cmc/cmc/hashmap/ext/code.h index 7ddafaf..fa22ca8 100644 --- a/src/cmc/cmc/hashmap/ext/code.h +++ b/src/cmc/cmc/hashmap/ext/code.h @@ -41,8 +41,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY( } struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; diff --git a/src/cmc/cmc/hashmap/ext/header.h b/src/cmc/cmc/hashmap/ext/header.h index ab15d5c..a76a0bf 100644 --- a/src/cmc/cmc/hashmap/ext/header.h +++ b/src/cmc/cmc/hashmap/ext/header.h @@ -33,8 +33,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _release)(struct SNAME _map_); #endif /* CMC_EXT_INIT */ diff --git a/src/cmc/cmc/hashmap/header.h b/src/cmc/cmc/hashmap/header.h index c69e79c..11cd80f 100644 --- a/src/cmc/cmc/hashmap/header.h +++ b/src/cmc/cmc/hashmap/header.h @@ -60,13 +60,12 @@ struct CMC_DEF_FVAL(SNAME) struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value); diff --git a/src/cmc/cmc/hashmap/struct.h b/src/cmc/cmc/hashmap/struct.h index 7e75a0d..c4d2e29 100644 --- a/src/cmc/cmc/hashmap/struct.h +++ b/src/cmc/cmc/hashmap/struct.h @@ -40,7 +40,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/hashmultimap/code.h b/src/cmc/cmc/hashmultimap/code.h index 7f7c296..53fe8cd 100644 --- a/src/cmc/cmc/hashmultimap/code.h +++ b/src/cmc/cmc/hashmultimap/code.h @@ -39,8 +39,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY( } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -167,7 +167,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_) _map_->alloc->free(_map_); } -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -218,7 +218,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) _map_->count++; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, create); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -250,7 +250,7 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, update); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -314,7 +314,7 @@ size_t CMC_(PFX, _update_all)(struct SNAME *_map_, K key, V new_value, V **old_v _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, update); + CMC_CALLBACKS_CALL(_map_); return index; } @@ -401,7 +401,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) _map_->count--; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, delete); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -496,7 +496,7 @@ size_t CMC_(PFX, _remove_all)(struct SNAME *_map_, K key, V **out_values) _map_->count -= index; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, delete); + CMC_CALLBACKS_CALL(_map_); return index; } @@ -547,7 +547,7 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -598,7 +598,7 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -625,7 +625,7 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return entry->value; } @@ -652,7 +652,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return &(entry->value); } @@ -667,7 +667,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return result; } @@ -813,7 +813,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity) success: - CMC_CALLBACKS_CALL(_map_, resize); + CMC_CALLBACKS_CALL(_map_); return true; } diff --git a/src/cmc/cmc/hashmultimap/header.h b/src/cmc/cmc/hashmultimap/header.h index ec3f2e0..015d062 100644 --- a/src/cmc/cmc/hashmultimap/header.h +++ b/src/cmc/cmc/hashmultimap/header.h @@ -60,13 +60,12 @@ struct CMC_DEF_FVAL(SNAME) struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, - struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); + struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value); diff --git a/src/cmc/cmc/hashmultimap/struct.h b/src/cmc/cmc/hashmultimap/struct.h index 291e7a7..9bb6042 100644 --- a/src/cmc/cmc/hashmultimap/struct.h +++ b/src/cmc/cmc/hashmultimap/struct.h @@ -40,7 +40,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/hashmultiset/code.h b/src/cmc/cmc/hashmultiset/code.h index 5f82358..6a225ee 100644 --- a/src/cmc/cmc/hashmultiset/code.h +++ b/src/cmc/cmc/hashmultiset/code.h @@ -37,7 +37,7 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL( } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -133,7 +133,7 @@ void CMC_(PFX, _free)(struct SNAME *_set_) _set_->alloc->free(_set_); } -void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -173,7 +173,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) _set_->cardinality++; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, create); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -208,7 +208,7 @@ success: _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, create); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -257,7 +257,7 @@ success: _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, update); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -297,7 +297,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) _set_->cardinality--; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, delete); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -333,7 +333,7 @@ size_t CMC_(PFX, _remove_all)(struct SNAME *_set_, V value) _set_->cardinality -= removed; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, delete); + CMC_CALLBACKS_CALL(_set_); return removed; } @@ -374,7 +374,7 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -415,7 +415,7 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -430,7 +430,7 @@ size_t CMC_(PFX, _multiplicity_of)(struct SNAME *_set_, V value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); if (!entry) return 0; @@ -448,7 +448,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return result; } @@ -594,7 +594,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_set_, size_t capacity) success: - CMC_CALLBACKS_CALL(_set_, resize); + CMC_CALLBACKS_CALL(_set_); return true; } diff --git a/src/cmc/cmc/hashmultiset/header.h b/src/cmc/cmc/hashmultiset/header.h index 4475af4..08aeb68 100644 --- a/src/cmc/cmc/hashmultiset/header.h +++ b/src/cmc/cmc/hashmultiset/header.h @@ -42,12 +42,11 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_set_); void CMC_(PFX, _free)(struct SNAME *_set_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value); bool CMC_(PFX, _insert_many)(struct SNAME *_set_, V value, size_t count); diff --git a/src/cmc/cmc/hashmultiset/struct.h b/src/cmc/cmc/hashmultiset/struct.h index f469ac0..4d52538 100644 --- a/src/cmc/cmc/hashmultiset/struct.h +++ b/src/cmc/cmc/hashmultiset/struct.h @@ -39,7 +39,7 @@ struct SNAME /* Key function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/hashset/code.h b/src/cmc/cmc/hashset/code.h index 239c883..912222b 100644 --- a/src/cmc/cmc/hashset/code.h +++ b/src/cmc/cmc/hashset/code.h @@ -36,7 +36,7 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL( } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -131,7 +131,7 @@ void CMC_(PFX, _free)(struct SNAME *_set_) _set_->alloc->free(_set_); } -void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -211,7 +211,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) _set_->count++; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, create); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -243,7 +243,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) _set_->count--; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, delete); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -284,7 +284,7 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -325,7 +325,7 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -340,7 +340,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return result; } @@ -474,7 +474,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_set_, size_t capacity) success: - CMC_CALLBACKS_CALL(_set_, resize); + CMC_CALLBACKS_CALL(_set_); return true; } diff --git a/src/cmc/cmc/hashset/header.h b/src/cmc/cmc/hashset/header.h index 23f266b..584bf80 100644 --- a/src/cmc/cmc/hashset/header.h +++ b/src/cmc/cmc/hashset/header.h @@ -42,12 +42,11 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_set_); void CMC_(PFX, _free)(struct SNAME *_set_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value); bool CMC_(PFX, _remove)(struct SNAME *_set_, V value); diff --git a/src/cmc/cmc/hashset/struct.h b/src/cmc/cmc/hashset/struct.h index e36c377..e7f3594 100644 --- a/src/cmc/cmc/hashset/struct.h +++ b/src/cmc/cmc/hashset/struct.h @@ -38,7 +38,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/heap/code.h b/src/cmc/cmc/heap/code.h index 9d12fd1..3cf97b5 100644 --- a/src/cmc/cmc/heap/code.h +++ b/src/cmc/cmc/heap/code.h @@ -36,7 +36,7 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, enum cmc_heap_order HO, struct CM } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -118,8 +118,7 @@ void CMC_(PFX, _free)(struct SNAME *_heap_) _heap_->alloc->free(_heap_); } -void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -158,7 +157,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, create); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -184,7 +183,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_heap_) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, delete); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -203,7 +202,7 @@ V CMC_(PFX, _peek)(struct SNAME *_heap_) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, read); + CMC_CALLBACKS_CALL(_heap_); return _heap_->buffer[0]; } @@ -227,7 +226,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value) } } - CMC_CALLBACKS_CALL(_heap_, read); + CMC_CALLBACKS_CALL(_heap_); return result; } @@ -309,7 +308,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_heap_, size_t capacity) success: - CMC_CALLBACKS_CALL(_heap_, resize); + CMC_CALLBACKS_CALL(_heap_); return true; } diff --git a/src/cmc/cmc/heap/header.h b/src/cmc/cmc/heap/header.h index 29ef3a8..0f74d72 100644 --- a/src/cmc/cmc/heap/header.h +++ b/src/cmc/cmc/heap/header.h @@ -42,12 +42,11 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_heap_); void CMC_(PFX, _free)(struct SNAME *_heap_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value); bool CMC_(PFX, _remove)(struct SNAME *_heap_); diff --git a/src/cmc/cmc/heap/struct.h b/src/cmc/cmc/heap/struct.h index 3dc51ea..1e7a150 100644 --- a/src/cmc/cmc/heap/struct.h +++ b/src/cmc/cmc/heap/struct.h @@ -37,7 +37,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/intervalheap/code.h b/src/cmc/cmc/intervalheap/code.h index 6a5d307..3e3dd59 100644 --- a/src/cmc/cmc/intervalheap/code.h +++ b/src/cmc/cmc/intervalheap/code.h @@ -37,8 +37,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -121,8 +121,7 @@ void CMC_(PFX, _free)(struct SNAME *_heap_) _heap_->alloc->free(_heap_); } -void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -195,7 +194,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value) /* else no float up required */ } - CMC_CALLBACKS_CALL(_heap_, create); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -251,7 +250,7 @@ success: _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, delete); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -307,7 +306,7 @@ success: _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, delete); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -347,7 +346,7 @@ bool CMC_(PFX, _update_max)(struct SNAME *_heap_, V value) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, update); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -387,7 +386,7 @@ bool CMC_(PFX, _update_min)(struct SNAME *_heap_, V value) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, update); + CMC_CALLBACKS_CALL(_heap_); return true; } @@ -406,7 +405,7 @@ V CMC_(PFX, _max)(struct SNAME *_heap_) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, read); + CMC_CALLBACKS_CALL(_heap_); /* If there is only one element, then the maximum element is the */ /* same as the one in the MinHeap */ @@ -430,7 +429,7 @@ V CMC_(PFX, _min)(struct SNAME *_heap_) _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, read); + CMC_CALLBACKS_CALL(_heap_); return _heap_->buffer[0][0]; } @@ -454,7 +453,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value) } } - CMC_CALLBACKS_CALL(_heap_, read); + CMC_CALLBACKS_CALL(_heap_); return result; } @@ -549,7 +548,7 @@ success: _heap_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_heap_, resize); + CMC_CALLBACKS_CALL(_heap_); return true; } diff --git a/src/cmc/cmc/intervalheap/header.h b/src/cmc/cmc/intervalheap/header.h index 7d69a93..68107c5 100644 --- a/src/cmc/cmc/intervalheap/header.h +++ b/src/cmc/cmc/intervalheap/header.h @@ -42,13 +42,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Functions */ /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_heap_); void CMC_(PFX, _free)(struct SNAME *_heap_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value); bool CMC_(PFX, _remove_max)(struct SNAME *_heap_); diff --git a/src/cmc/cmc/intervalheap/struct.h b/src/cmc/cmc/intervalheap/struct.h index 4c6ea42..8bcb17b 100644 --- a/src/cmc/cmc/intervalheap/struct.h +++ b/src/cmc/cmc/intervalheap/struct.h @@ -38,7 +38,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/linkedlist/code.h b/src/cmc/cmc/linkedlist/code.h index 65f8040..677b3a6 100644 --- a/src/cmc/cmc/linkedlist/code.h +++ b/src/cmc/cmc/linkedlist/code.h @@ -35,8 +35,8 @@ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val) return CMC_(PFX, _new_custom)(f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -105,8 +105,7 @@ void CMC_(PFX, _free)(struct SNAME *_list_) _list_->alloc->free(_list_); } -void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -150,7 +149,7 @@ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value) _list_->count++; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -191,7 +190,7 @@ bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index) _list_->count++; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -222,7 +221,7 @@ bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value) _list_->count++; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -252,7 +251,7 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_list_) _list_->count--; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -297,7 +296,7 @@ bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index) _list_->count--; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -327,7 +326,7 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_list_) _list_->count--; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -346,7 +345,7 @@ V CMC_(PFX, _front)(struct SNAME *_list_) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->head->value; } @@ -374,7 +373,7 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) if (scan == NULL) return (V){ 0 }; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return scan->value; } @@ -402,7 +401,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index) if (scan == NULL) return NULL; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return &(scan->value); } @@ -421,7 +420,7 @@ V CMC_(PFX, _back)(struct SNAME *_list_) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->tail->value; } @@ -449,7 +448,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) scan = scan->next; } - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return result; } diff --git a/src/cmc/cmc/linkedlist/header.h b/src/cmc/cmc/linkedlist/header.h index 2082677..1356eb7 100644 --- a/src/cmc/cmc/linkedlist/header.h +++ b/src/cmc/cmc/linkedlist/header.h @@ -42,13 +42,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Functions */ /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_list_); void CMC_(PFX, _free)(struct SNAME *_list_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value); bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index); diff --git a/src/cmc/cmc/linkedlist/struct.h b/src/cmc/cmc/linkedlist/struct.h index e7572c2..4e09228 100644 --- a/src/cmc/cmc/linkedlist/struct.h +++ b/src/cmc/cmc/linkedlist/struct.h @@ -41,7 +41,7 @@ struct SNAME struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; diff --git a/src/cmc/cmc/list/code.h b/src/cmc/cmc/list/code.h index a65a9ac..e025420 100644 --- a/src/cmc/cmc/list/code.h +++ b/src/cmc/cmc/list/code.h @@ -43,11 +43,11 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va } #ifdef CMC_SAC -struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) #else -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) #endif { #ifdef CMC_DEV @@ -138,8 +138,7 @@ void CMC_(PFX, _free)(struct SNAME *_list_) _list_->alloc->free(_list_); } -void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -188,7 +187,7 @@ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value) _list_->count++; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -222,7 +221,7 @@ bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index) _list_->count++; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -247,7 +246,7 @@ bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value) _list_->buffer[_list_->count++] = value; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -269,7 +268,7 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_list_) _list_->buffer[--_list_->count] = (V){ 0 }; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -297,7 +296,7 @@ bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index) _list_->buffer[--_list_->count] = (V){ 0 }; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -309,12 +308,16 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_list_) #endif if (CMC_(PFX, _empty)(_list_)) + { + _list_->flag = CMC_FLAG_EMPTY; + CMC_CALLBACKS_CALL(_list_); return false; + } _list_->buffer[--_list_->count] = (V){ 0 }; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -333,7 +336,7 @@ V CMC_(PFX, _front)(struct SNAME *_list_) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->buffer[0]; } @@ -347,18 +350,20 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; + CMC_CALLBACKS_CALL(_list_); return (V){ 0 }; } if (index >= _list_->count) { _list_->flag = CMC_FLAG_RANGE; + CMC_CALLBACKS_CALL(_list_); return (V){ 0 }; } _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->buffer[index]; } @@ -383,7 +388,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return &(_list_->buffer[index]); } @@ -402,7 +407,7 @@ V CMC_(PFX, _back)(struct SNAME *_list_) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->buffer[_list_->count - 1]; } @@ -440,7 +445,7 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start) } } - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return result; } @@ -464,7 +469,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) } } - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return result; } @@ -567,7 +572,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_list_, size_t capacity) _list_->buffer = new_buffer; _list_->capacity = capacity; - CMC_CALLBACKS_CALL(_list_, resize); + CMC_CALLBACKS_CALL(_list_); return true; } diff --git a/src/cmc/cmc/list/ext/code.h b/src/cmc/cmc/list/ext/code.h index 50e51e3..e19cad1 100644 --- a/src/cmc/cmc/list/ext/code.h +++ b/src/cmc/cmc/list/ext/code.h @@ -48,11 +48,11 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va } #ifdef CMC_SAC -struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) #else -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) #endif { #ifdef CMC_DEV @@ -397,7 +397,7 @@ bool CMC_(PFX, _seq_push_front)(struct SNAME *_list_, V *values, size_t size) _list_->count += size; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -443,7 +443,7 @@ bool CMC_(PFX, _seq_push_at)(struct SNAME *_list_, V *values, size_t size, size_ _list_->count += size; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -476,7 +476,7 @@ bool CMC_(PFX, _seq_push_back)(struct SNAME *_list_, V *values, size_t size) _list_->count += size; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -508,7 +508,7 @@ bool CMC_(PFX, _seq_pop_at)(struct SNAME *_list_, size_t from, size_t to) _list_->count -= to - from + 1; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -556,7 +556,7 @@ struct SNAME *CMC_(PFX, _seq_sublist)(struct SNAME *_list_, size_t from, size_t _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return result; } diff --git a/src/cmc/cmc/list/ext/header.h b/src/cmc/cmc/list/ext/header.h index 7fa489f..c621891 100644 --- a/src/cmc/cmc/list/ext/header.h +++ b/src/cmc/cmc/list/ext/header.h @@ -32,12 +32,12 @@ #ifdef CMC_SAC struct SNAME CMC_(PFX, _init)(struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); #else struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); #endif void CMC_(PFX, _release)(struct SNAME _list_); diff --git a/src/cmc/cmc/list/header.h b/src/cmc/cmc/list/header.h index d9fb587..4230152 100644 --- a/src/cmc/cmc/list/header.h +++ b/src/cmc/cmc/list/header.h @@ -42,18 +42,17 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ #ifdef CMC_SAC struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); #else struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); #endif void CMC_(PFX, _clear)(struct SNAME *_list_); void CMC_(PFX, _free)(struct SNAME *_list_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value); bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index); diff --git a/src/cmc/cmc/list/struct.h b/src/cmc/cmc/list/struct.h index 214a478..3f8dc89 100644 --- a/src/cmc/cmc/list/struct.h +++ b/src/cmc/cmc/list/struct.h @@ -39,7 +39,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/queue/code.h b/src/cmc/cmc/queue/code.h index 78a90b3..bb1e8dd 100644 --- a/src/cmc/cmc/queue/code.h +++ b/src/cmc/cmc/queue/code.h @@ -34,8 +34,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -121,8 +121,7 @@ void CMC_(PFX, _free)(struct SNAME *_queue_) _queue_->alloc->free(_queue_); } -void CMC_(PFX, _customize)(struct SNAME *_queue_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_queue_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -158,7 +157,7 @@ bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value) _queue_->count++; _queue_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_queue_, create); + CMC_CALLBACKS_CALL(_queue_); return true; } @@ -181,7 +180,7 @@ bool CMC_(PFX, _dequeue)(struct SNAME *_queue_) _queue_->count--; _queue_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_queue_, delete); + CMC_CALLBACKS_CALL(_queue_); return true; } @@ -200,7 +199,7 @@ V CMC_(PFX, _peek)(struct SNAME *_queue_) _queue_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_queue_, read); + CMC_CALLBACKS_CALL(_queue_); return _queue_->buffer[_queue_->front]; } @@ -226,7 +225,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_queue_, V value) i = (i + 1) % _queue_->capacity; } - CMC_CALLBACKS_CALL(_queue_, read); + CMC_CALLBACKS_CALL(_queue_); return result; } @@ -317,7 +316,7 @@ success: _queue_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_queue_, resize); + CMC_CALLBACKS_CALL(_queue_); return true; } diff --git a/src/cmc/cmc/queue/ext/code.h b/src/cmc/cmc/queue/ext/code.h index 33fc523..05204f5 100644 --- a/src/cmc/cmc/queue/ext/code.h +++ b/src/cmc/cmc/queue/ext/code.h @@ -39,8 +39,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; diff --git a/src/cmc/cmc/queue/ext/header.h b/src/cmc/cmc/queue/ext/header.h index 8ad7c5b..93035b5 100644 --- a/src/cmc/cmc/queue/ext/header.h +++ b/src/cmc/cmc/queue/ext/header.h @@ -31,8 +31,8 @@ #ifdef CMC_EXT_INIT struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _release)(struct SNAME _queue_); #endif /* CMC_EXT_INIT */ diff --git a/src/cmc/cmc/queue/header.h b/src/cmc/cmc/queue/header.h index 3c3648f..1f4002e 100644 --- a/src/cmc/cmc/queue/header.h +++ b/src/cmc/cmc/queue/header.h @@ -41,13 +41,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_queue_); void CMC_(PFX, _free)(struct SNAME *_queue_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_queue_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_queue_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value); bool CMC_(PFX, _dequeue)(struct SNAME *_queue_); diff --git a/src/cmc/cmc/queue/struct.h b/src/cmc/cmc/queue/struct.h index 9860b07..e77e5e6 100644 --- a/src/cmc/cmc/queue/struct.h +++ b/src/cmc/cmc/queue/struct.h @@ -39,7 +39,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/sortedlist/code.h b/src/cmc/cmc/sortedlist/code.h index b8f00fa..b569dbf 100644 --- a/src/cmc/cmc/sortedlist/code.h +++ b/src/cmc/cmc/sortedlist/code.h @@ -37,8 +37,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -110,8 +110,7 @@ void CMC_(PFX, _free)(struct SNAME *_list_) _list_->alloc->free(_list_); } -void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -146,7 +145,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_list_, V value) _list_->is_sorted = false; _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, create); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -175,7 +174,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_list_, size_t index) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, delete); + CMC_CALLBACKS_CALL(_list_); return true; } @@ -196,7 +195,7 @@ V CMC_(PFX, _max)(struct SNAME *_list_) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->buffer[_list_->count - 1]; } @@ -217,7 +216,7 @@ V CMC_(PFX, _min)(struct SNAME *_list_) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->buffer[0]; } @@ -244,7 +243,7 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return _list_->buffer[index]; } @@ -259,7 +258,7 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start) CMC_(PFX, _sort)(_list_); - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); if (from_start) { @@ -282,7 +281,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) CMC_(PFX, _sort)(_list_); - CMC_CALLBACKS_CALL(_list_, read); + CMC_CALLBACKS_CALL(_list_); return CMC_(PFX, _impl_binary_search_first)(_list_, value) < _list_->count; } @@ -364,7 +363,7 @@ success: _list_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_list_, resize); + CMC_CALLBACKS_CALL(_list_); return true; } diff --git a/src/cmc/cmc/sortedlist/header.h b/src/cmc/cmc/sortedlist/header.h index 04321cc..f5f405d 100644 --- a/src/cmc/cmc/sortedlist/header.h +++ b/src/cmc/cmc/sortedlist/header.h @@ -41,13 +41,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_list_); void CMC_(PFX, _free)(struct SNAME *_list_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_list_, V value); bool CMC_(PFX, _remove)(struct SNAME *_list_, size_t index); diff --git a/src/cmc/cmc/sortedlist/struct.h b/src/cmc/cmc/sortedlist/struct.h index c9456c4..4c0a8e5 100644 --- a/src/cmc/cmc/sortedlist/struct.h +++ b/src/cmc/cmc/sortedlist/struct.h @@ -37,7 +37,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/stack/code.h b/src/cmc/cmc/stack/code.h index 5c52095..f48ed6b 100644 --- a/src/cmc/cmc/stack/code.h +++ b/src/cmc/cmc/stack/code.h @@ -34,8 +34,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -108,8 +108,7 @@ void CMC_(PFX, _free)(struct SNAME *_stack_) _stack_->alloc->free(_stack_); } -void CMC_(PFX, _customize)(struct SNAME *_stack_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_stack_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -143,7 +142,7 @@ bool CMC_(PFX, _push)(struct SNAME *_stack_, V value) _stack_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_stack_, create); + CMC_CALLBACKS_CALL(_stack_); return true; } @@ -164,7 +163,7 @@ bool CMC_(PFX, _pop)(struct SNAME *_stack_) _stack_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_stack_, delete); + CMC_CALLBACKS_CALL(_stack_); return true; } @@ -183,7 +182,7 @@ V CMC_(PFX, _top)(struct SNAME *_stack_) _stack_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_stack_, read); + CMC_CALLBACKS_CALL(_stack_); return _stack_->buffer[_stack_->count - 1]; } @@ -207,7 +206,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_stack_, V value) } } - CMC_CALLBACKS_CALL(_stack_, read); + CMC_CALLBACKS_CALL(_stack_); return result; } @@ -289,7 +288,7 @@ success: _stack_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_stack_, resize); + CMC_CALLBACKS_CALL(_stack_); return true; } diff --git a/src/cmc/cmc/stack/ext/code.h b/src/cmc/cmc/stack/ext/code.h index b72a470..d29b5d0 100644 --- a/src/cmc/cmc/stack/ext/code.h +++ b/src/cmc/cmc/stack/ext/code.h @@ -39,8 +39,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; diff --git a/src/cmc/cmc/stack/ext/header.h b/src/cmc/cmc/stack/ext/header.h index e94db40..5ad0c37 100644 --- a/src/cmc/cmc/stack/ext/header.h +++ b/src/cmc/cmc/stack/ext/header.h @@ -31,8 +31,8 @@ #ifdef CMC_EXT_INIT struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _release)(struct SNAME _stack_); #endif /* CMC_EXT_INIT */ diff --git a/src/cmc/cmc/stack/header.h b/src/cmc/cmc/stack/header.h index 9eabcab..adbb373 100644 --- a/src/cmc/cmc/stack/header.h +++ b/src/cmc/cmc/stack/header.h @@ -41,13 +41,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_stack_); void CMC_(PFX, _free)(struct SNAME *_stack_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_stack_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_stack_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _push)(struct SNAME *_stack_, V value); bool CMC_(PFX, _pop)(struct SNAME *_stack_); diff --git a/src/cmc/cmc/stack/struct.h b/src/cmc/cmc/stack/struct.h index a0ddc5c..5db18dd 100644 --- a/src/cmc/cmc/stack/struct.h +++ b/src/cmc/cmc/stack/struct.h @@ -36,7 +36,7 @@ struct SNAME /* Value function table */ struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; }; diff --git a/src/cmc/cmc/treemap/code.h b/src/cmc/cmc/treemap/code.h index 24981a7..5717087 100644 --- a/src/cmc/cmc/treemap/code.h +++ b/src/cmc/cmc/treemap/code.h @@ -41,7 +41,7 @@ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF } struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -152,7 +152,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_) _map_->alloc->free(_map_); } -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -241,7 +241,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) _map_->count++; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, create); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -267,7 +267,7 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, update); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -409,7 +409,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) _map_->count--; _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, delete); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -438,7 +438,7 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -467,7 +467,7 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return true; } @@ -494,7 +494,7 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return node->value; } @@ -521,7 +521,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) _map_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return &(node->value); } @@ -534,7 +534,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) bool result = CMC_(PFX, _impl_get_node)(_map_, key) != NULL; - CMC_CALLBACKS_CALL(_map_, read); + CMC_CALLBACKS_CALL(_map_); return result; } diff --git a/src/cmc/cmc/treemap/header.h b/src/cmc/cmc/treemap/header.h index 7af9f27..200e865 100644 --- a/src/cmc/cmc/treemap/header.h +++ b/src/cmc/cmc/treemap/header.h @@ -60,12 +60,11 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val, - struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); + CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value); diff --git a/src/cmc/cmc/treemap/struct.h b/src/cmc/cmc/treemap/struct.h index fcaa75e..3e0475a 100644 --- a/src/cmc/cmc/treemap/struct.h +++ b/src/cmc/cmc/treemap/struct.h @@ -41,7 +41,7 @@ struct SNAME struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; diff --git a/src/cmc/cmc/treeset/code.h b/src/cmc/cmc/treeset/code.h index c011fd9..bc88d67 100644 --- a/src/cmc/cmc/treeset/code.h +++ b/src/cmc/cmc/treeset/code.h @@ -40,8 +40,8 @@ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val) return CMC_(PFX, _new_custom)(f_val, NULL, NULL); } -struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks) +struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -147,7 +147,7 @@ void CMC_(PFX, _free)(struct SNAME *_set_) _set_->alloc->free(_set_); } -void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) +void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks) { #ifdef CMC_DEV CMC_DEV_FCALL; @@ -178,6 +178,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) if (!_set_->root) { _set_->flag = CMC_FLAG_ALLOC; + CMC_CALLBACKS_CALL(_set_); return false; } } @@ -210,6 +211,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) if (!parent->left) { _set_->flag = CMC_FLAG_ALLOC; + CMC_CALLBACKS_CALL(_set_); return false; } @@ -223,6 +225,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) if (!parent->right) { _set_->flag = CMC_FLAG_ALLOC; + CMC_CALLBACKS_CALL(_set_); return false; } @@ -236,7 +239,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) _set_->count++; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, create); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -250,6 +253,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; + CMC_CALLBACKS_CALL(_set_); return false; } @@ -258,6 +262,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) if (!node) { _set_->flag = CMC_FLAG_NOT_FOUND; + CMC_CALLBACKS_CALL(_set_); return false; } @@ -373,7 +378,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) _set_->count--; _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, delete); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -400,7 +405,7 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -427,7 +432,7 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) _set_->flag = CMC_FLAG_OK; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return true; } @@ -440,7 +445,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) bool result = CMC_(PFX, _impl_get_node)(_set_, value) != NULL; - CMC_CALLBACKS_CALL(_set_, read); + CMC_CALLBACKS_CALL(_set_); return result; } diff --git a/src/cmc/cmc/treeset/header.h b/src/cmc/cmc/treeset/header.h index a9d66e7..9c7485f 100644 --- a/src/cmc/cmc/treeset/header.h +++ b/src/cmc/cmc/treeset/header.h @@ -42,13 +42,12 @@ struct CMC_DEF_FVAL(SNAME) /* Collection Functions */ /* Collection Allocation and Deallocation */ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val); -struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE *alloc, + CMC_CALLBACK_TYPE callbacks); void CMC_(PFX, _clear)(struct SNAME *_set_); void CMC_(PFX, _free)(struct SNAME *_set_); /* Customization of Allocation and Callbacks */ -void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, - struct CMC_CALLBACKS_NAME *callbacks); +void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE *alloc, CMC_CALLBACK_TYPE callbacks); /* Collection Input and Output */ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value); bool CMC_(PFX, _remove)(struct SNAME *_set_, V value); diff --git a/src/cmc/cmc/treeset/struct.h b/src/cmc/cmc/treeset/struct.h index 7635b49..8b65b8f 100644 --- a/src/cmc/cmc/treeset/struct.h +++ b/src/cmc/cmc/treeset/struct.h @@ -38,7 +38,7 @@ struct SNAME struct CMC_DEF_FVAL(SNAME) * f_val; /* Custom allocation functions */ - struct CMC_ALLOC_NODE_NAME *alloc; + CMC_ALLOC_TYPE *alloc; /* Custom callback functions */ CMC_CALLBACKS_DECL; diff --git a/src/cmc/cor/alloc.h b/src/cmc/cor/alloc.h index 809dd40..6062d70 100644 --- a/src/cmc/cor/alloc.h +++ b/src/cmc/cor/alloc.h @@ -44,7 +44,6 @@ #endif #include "core.h" - /** * struct cmc_alloc_node * @@ -52,6 +51,9 @@ * functions. The cmc_alloc_node_default is the default heap allocator provided * by the standard library. */ + +#define CMC_ALLOC_TYPE struct CMC_ALLOC_NODE_NAME + static struct CMC_ALLOC_NODE_NAME { void *(*malloc)(size_t); diff --git a/src/cmc/cor/callbacks.h b/src/cmc/cor/callbacks.h index 3a204af..29d856d 100644 --- a/src/cmc/cor/callbacks.h +++ b/src/cmc/cor/callbacks.h @@ -35,49 +35,27 @@ #ifndef CMC_COR_CALLBACKS_H #define CMC_COR_CALLBACKS_H -#ifdef CMC_CAMEL_CASE -#define CMC_CALLBACKS_NAME CMCCallbacks -#else -#define CMC_CALLBACKS_NAME cmc_callbacks -#endif +typedef void (*cmc_callback)(const char func_name[], void *self); +#define CMC_CALLBACK_TYPE cmc_callback -#ifdef CMC_NO_CALLBACKS +#ifdef CMC_CALLBACKS + +#define CMC_CALLBACKS_DECL cmc_callback callbacks +#define CMC_CALLBACKS_MAYBE_UNUSED(param) +#define CMC_CALLBACKS_GET(ds) (ds)->callbacks +#define CMC_CALLBACKS_ASSIGN(ds, cb) CMC_CALLBACKS_GET(ds) = cb +#define CMC_CALLBACKS_CALL(ds) \ + if (CMC_CALLBACKS_GET(ds)) \ + CMC_CALLBACKS_GET(ds)(__func__, (void *)ds); + +#else #define CMC_CALLBACKS_DECL #define CMC_CALLBACKS_MAYBE_UNUSED(param) CMC_UNUSED_PARAM(param) /* Prevent -Wunused-parameter */ #define CMC_CALLBACKS_GET(ds) NULL /* Helps with compatibility */ #define CMC_CALLBACKS_ASSIGN(ds, cb) -#define CMC_CALLBACKS_CALL(ds, cb) - -#else - -#define CMC_CALLBACKS_DECL struct CMC_CALLBACKS_NAME *callbacks -#define CMC_CALLBACKS_MAYBE_UNUSED(param) -#define CMC_CALLBACKS_GET(ds) (ds)->callbacks -#define CMC_CALLBACKS_ASSIGN(ds, cb) CMC_CALLBACKS_GET(ds) = cb -#define CMC_CALLBACKS_CALL(ds, cb) \ - if (CMC_CALLBACKS_GET(ds) && CMC_CALLBACKS_GET(ds)->cb) \ - CMC_CALLBACKS_GET(ds)->cb(); +#define CMC_CALLBACKS_CALL(ds) #endif -/** - * struct cmc_callbacks - * - * Callback node. Each collection will call one of these functions when: - * - create : an element was successfully added to the collection - * - read : the collection was successfully queried about an element - * - update : an element in the collection was successfully updated - * - delete : an element was successfully removed from the collection - * - resize : the collection was full and successfully resized - */ -struct CMC_CALLBACKS_NAME -{ - void (*create)(void); - void (*read)(void); - void (*update)(void); - void (*delete)(void); - void (*resize)(void); -}; - #endif /* CMC_COR_CALLBACKS_H */ diff --git a/src/cmc/cor/dev.h b/src/cmc/cor/dev.h index a91faa8..25cbe23 100644 --- a/src/cmc/cor/dev.h +++ b/src/cmc/cor/dev.h @@ -39,6 +39,8 @@ * Macros for tracing and debugging data structures when CMC_DEV is enabled */ +#ifndef CMC_DEV_FCALL #define CMC_DEV_FCALL cmc_log_trace("fcall") +#endif #endif /* CMC_COR_DEV_H */ diff --git a/tests/Makefile b/tests/Makefile index 08b4f63..359f84d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-Wall -Wextra -Werror -fprofile-arcs -ftest-coverage -ftime-report -g -O0 +CFLAGS=-Wall -Wextra -Werror -fprofile-arcs -ftest-coverage -ftime-report -g -O0 -DCMC_CALLBACKS INCLUDE=-I ../src OUTDIR=out diff --git a/tests/unt_deque.h b/tests/unt_deque.h index 92ce83f..ca4850b 100644 --- a/tests/unt_deque.h +++ b/tests/unt_deque.h @@ -287,7 +287,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { }); CMC_CREATE_TEST(PFX##_push_front(), { - total_create = 0; struct deque *d = d_new_custom(100, d_fval, NULL, callbacks); cmc_assert_not_equals(ptr, NULL, d); @@ -296,7 +295,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { cmc_assert(d_push_front(d, 10)); cmc_assert_equals(size_t, 1, d_count(d)); - cmc_assert_equals(int32_t, 1, total_create); cmc_assert_equals(int32_t, CMC_FLAG_OK, d_flag(d)); d_customize(d, NULL, NULL); @@ -328,13 +326,9 @@ CMC_CREATE_UNIT(CMCDeque, true, { cmc_assert_equals(size_t, 50005000, sum); d_free(d); - - cmc_assert_equals(int32_t, 1, total_create); - total_create = 0; }); CMC_CREATE_TEST(PFX##_push_back(), { - total_create = 0; struct deque *d = d_new_custom(100, d_fval, NULL, callbacks); cmc_assert_not_equals(ptr, NULL, d); @@ -343,7 +337,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { cmc_assert(d_push_front(d, 10)); cmc_assert_equals(size_t, 1, d_count(d)); - cmc_assert_equals(int32_t, 1, total_create); cmc_assert_equals(int32_t, CMC_FLAG_OK, d_flag(d)); d_customize(d, NULL, NULL); @@ -375,9 +368,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { cmc_assert_equals(size_t, 50005000, sum); d_free(d); - - cmc_assert_equals(int32_t, 1, total_create); - total_create = 0; }); CMC_CREATE_TEST(PFX##_pop_front(), { @@ -743,7 +733,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { }); CMC_CREATE_TEST(PFX##_resize(), { - total_resize = 0; struct deque *d = d_new_custom(100, d_fval, NULL, callbacks); cmc_assert_not_equals(ptr, NULL, d); @@ -753,16 +742,12 @@ CMC_CREATE_UNIT(CMCDeque, true, { cmc_assert(d_resize(d, 100)); cmc_assert_equals(size_t, 100, d_capacity(d)); - cmc_assert_equals(int32_t, 1, total_resize); - cmc_assert(d_resize(d, 200)); cmc_assert_equals(size_t, 200, d_capacity(d)); cmc_assert(d_resize(d, 100)); cmc_assert_equals(size_t, 100, d_capacity(d)); - cmc_assert_equals(int32_t, 3, total_resize); - for (size_t i = 0; i < 150; i++) { if (i % 2 == 0) @@ -805,7 +790,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { cmc_assert_equals(size_t, 11325, sum); d_free(d); - total_resize = 0; }); CMC_CREATE_TEST(PFX##_copy_of(), { @@ -1104,7 +1088,7 @@ CMC_CREATE_UNIT(CMCDeque, true, { // customize d->flag = CMC_FLAG_ERROR; - d_customize(d, &cmc_alloc_node_default, &(struct cmc_callbacks){ 0 }); + d_customize(d, &cmc_alloc_node_default, callbacks); cmc_assert_equals(int32_t, CMC_FLAG_OK, d_flag(d)); // push_front @@ -1180,88 +1164,6 @@ CMC_CREATE_UNIT(CMCDeque, true, { d_free(d); d_free(d2); }); - - CMC_CREATE_TEST(callbacks, { - struct deque *d = d_new_custom(100, d_fval, NULL, callbacks); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(d_push_front(d, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(d_push_back(d, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(d_pop_front(d)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(d_pop_back(d)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(d_push_front(d, 10)); - cmc_assert(d_push_front(d, 5)); - cmc_assert_equals(int32_t, 4, total_create); - - cmc_assert_equals(size_t, 5, d_front(d)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert_equals(size_t, 10, d_back(d)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(d_contains(d, 10)); - cmc_assert(!d_contains(d, 1)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(d_resize(d, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(d_resize(d, 10)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 4, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - d_customize(d, NULL, NULL); - - cmc_assert_equals(ptr, NULL, d->callbacks); - - d_clear(d); - cmc_assert(d_push_front(d, 10)); - cmc_assert(d_push_back(d, 10)); - cmc_assert(d_pop_front(d)); - cmc_assert(d_pop_back(d)); - cmc_assert(d_push_front(d, 10)); - cmc_assert(d_push_front(d, 5)); - cmc_assert_equals(size_t, 5, d_front(d)); - cmc_assert_equals(size_t, 10, d_back(d)); - cmc_assert(d_contains(d, 10)); - cmc_assert(!d_contains(d, 1)); - cmc_assert(d_resize(d, 1000)); - cmc_assert(d_resize(d, 10)); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 4, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, d->callbacks); - - d_free(d); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCDequeIter, true, { diff --git a/tests/unt_hashbidimap.h b/tests/unt_hashbidimap.h index 74a592c..c8fe6a3 100644 --- a/tests/unt_hashbidimap.h +++ b/tests/unt_hashbidimap.h @@ -460,7 +460,7 @@ CMC_CREATE_UNIT(CMCHashBidiMap, true, { struct hashbidimap *map = hbm_new_custom( 10000, 0.6, hbm_fkey, hbm_fval, &(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free }, - &(struct cmc_callbacks){ 0 }); + callbacks); cmc_assert_not_equals(ptr, NULL, map); @@ -489,7 +489,7 @@ CMC_CREATE_UNIT(CMCHashBidiMap, true, { struct hashbidimap *map = hbm_new_custom( 10000, 0.6, hbm_fkey, hbm_fval, &(struct cmc_alloc_node){ .malloc = malloc, .calloc = calloc, .realloc = realloc, .free = free }, - &(struct cmc_callbacks){ 0 }); + callbacks); cmc_assert_not_equals(ptr, NULL, map); @@ -582,7 +582,7 @@ CMC_CREATE_UNIT(CMCHashBidiMap, true, { cmc_assert_equals(int32_t, CMC_FLAG_OK, hbm_flag(map)); // customize - hbm_customize(map, &cmc_alloc_node_default, &(struct cmc_callbacks){ 0 }); + hbm_customize(map, &cmc_alloc_node_default, callbacks); cmc_assert_equals(int32_t, CMC_FLAG_OK, hbm_flag(map)); // Insert @@ -709,99 +709,6 @@ CMC_CREATE_UNIT(CMCHashBidiMap, true, { hbm_free(map); hbm_free(map2); }); - - CMC_CREATE_TEST(callbacks, { - struct hashbidimap *map = hbm_new_custom(100, 0.7, hbm_fkey, hbm_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, map); - cmc_assert_equals(ptr, callbacks, map->callbacks); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(hbm_insert(map, 10, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(hbm_update_key(map, 10, 5)); - cmc_assert_equals(int32_t, 1, total_update); - - cmc_assert(hbm_update_val(map, 5, 5)); - cmc_assert_equals(int32_t, 2, total_update); - - cmc_assert(hbm_insert(map, 10, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(hbm_remove_by_key(map, 5, NULL, NULL)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(hbm_remove_by_val(map, 10, NULL, NULL)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(hbm_insert(map, 1, 2)); - cmc_assert_equals(int32_t, 3, total_create); - - cmc_assert_equals(size_t, 1, hbm_get_key(map, 2)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert_equals(size_t, 2, hbm_get_val(map, 1)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(hbm_resize(map, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(hbm_resize(map, 200)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert(hbm_contains_key(map, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert(hbm_contains_val(map, 2)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert_equals(int32_t, 3, total_create); - cmc_assert_equals(int32_t, 4, total_read); - cmc_assert_equals(int32_t, 2, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - hbm_customize(map, NULL, NULL); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - hbm_clear(map); - cmc_assert(hbm_insert(map, 10, 10)); - cmc_assert(hbm_update_key(map, 10, 5)); - cmc_assert(hbm_update_val(map, 5, 5)); - cmc_assert(hbm_insert(map, 10, 10)); - cmc_assert(hbm_remove_by_key(map, 5, NULL, NULL)); - cmc_assert(hbm_remove_by_val(map, 10, NULL, NULL)); - cmc_assert(hbm_insert(map, 1, 2)); - cmc_assert_equals(size_t, 1, hbm_get_key(map, 2)); - cmc_assert_equals(size_t, 2, hbm_get_val(map, 1)); - cmc_assert(hbm_resize(map, 1000)); - cmc_assert(hbm_resize(map, 200)); - cmc_assert(hbm_contains_key(map, 1)); - cmc_assert(hbm_contains_val(map, 2)); - - cmc_assert_equals(int32_t, 3, total_create); - cmc_assert_equals(int32_t, 4, total_read); - cmc_assert_equals(int32_t, 2, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - hbm_free(map); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCHashBidiMapIter, true, { diff --git a/tests/unt_hashmap.h b/tests/unt_hashmap.h index 21741d4..c86be0e 100644 --- a/tests/unt_hashmap.h +++ b/tests/unt_hashmap.h @@ -802,84 +802,6 @@ CMC_CREATE_UNIT(CMCHashMap, true, { hm_free(map); hm_free(map2); }); - - CMC_CREATE_TEST(callbacks, { - struct hashmap *map = hm_new_custom(100, 0.6, hm_fkey, hm_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, map); - - cmc_assert(hm_insert(map, 1, 2)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(hm_update(map, 1, 10, NULL)); - cmc_assert_equals(int32_t, 1, total_update); - - cmc_assert(hm_remove(map, 1, NULL)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(hm_insert(map, 1, 2)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(hm_max(map, NULL, NULL)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(hm_min(map, NULL, NULL)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert_equals(size_t, 2, hm_get(map, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_not_equals(ptr, NULL, hm_get_ref(map, 1)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(hm_contains(map, 1)); - cmc_assert_equals(int32_t, 5, total_read); - - cmc_assert(hm_resize(map, 10000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(hm_resize(map, 500)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 1, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - hm_customize(map, NULL, NULL); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - hm_clear(map); - cmc_assert(hm_insert(map, 1, 2)); - cmc_assert(hm_update(map, 1, 10, NULL)); - cmc_assert(hm_remove(map, 1, NULL)); - cmc_assert(hm_insert(map, 1, 2)); - cmc_assert(hm_max(map, NULL, NULL)); - cmc_assert(hm_min(map, NULL, NULL)); - cmc_assert_equals(size_t, 2, hm_get(map, 1)); - cmc_assert_not_equals(ptr, NULL, hm_get_ref(map, 1)); - cmc_assert(hm_contains(map, 1)); - cmc_assert(hm_resize(map, 10000)); - cmc_assert(hm_resize(map, 500)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 1, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - hm_free(map); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); struct hashmap_fkey *hm_fkey_numhash = &(struct hashmap_fkey){ diff --git a/tests/unt_hashmultimap.h b/tests/unt_hashmultimap.h index d12efb4..4708008 100644 --- a/tests/unt_hashmultimap.h +++ b/tests/unt_hashmultimap.h @@ -464,106 +464,6 @@ CMC_CREATE_UNIT(CMCHashMultiMap, true, { hmm_free(map); hmm_free(map2); }); - - CMC_CREATE_TEST(callbacks, { - struct hashmultimap *map = hmm_new_custom(100, 0.8, hmm_fkey, hmm_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, map); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(hmm_insert(map, 1, 1)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(hmm_update(map, 1, 2, NULL)); - cmc_assert_equals(int32_t, 1, total_update); - - cmc_assert(hmm_insert(map, 1, 1)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert_equals(size_t, 2, hmm_update_all(map, 1, 3, NULL)); - cmc_assert_equals(int32_t, 2, total_update); - - cmc_assert(hmm_remove(map, 1, NULL)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(hmm_insert(map, 1, 2)); - cmc_assert_equals(int32_t, 3, total_create); - - cmc_assert_equals(size_t, 2, hmm_remove_all(map, 1, NULL)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(hmm_insert(map, 1, 2)); - cmc_assert_equals(int32_t, 4, total_create); - - cmc_assert(hmm_max(map, NULL, NULL)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(hmm_min(map, NULL, NULL)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert_equals(size_t, 2, hmm_get(map, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_not_equals(ptr, NULL, hmm_get_ref(map, 1)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(hmm_contains(map, 1)); - cmc_assert_equals(int32_t, 5, total_read); - - cmc_assert(hmm_resize(map, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(hmm_resize(map, 100)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 2, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - hmm_customize(map, NULL, NULL); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - hmm_clear(map); - cmc_assert(hmm_insert(map, 1, 1)); - cmc_assert(hmm_update(map, 1, 2, NULL)); - cmc_assert(hmm_insert(map, 1, 1)); - cmc_assert_equals(size_t, 2, hmm_update_all(map, 1, 3, NULL)); - cmc_assert(hmm_remove(map, 1, NULL)); - cmc_assert(hmm_insert(map, 1, 2)); - cmc_assert_equals(size_t, 2, hmm_remove_all(map, 1, NULL)); - cmc_assert(hmm_insert(map, 1, 2)); - cmc_assert(hmm_max(map, NULL, NULL)); - cmc_assert(hmm_min(map, NULL, NULL)); - cmc_assert_equals(size_t, 2, hmm_get(map, 1)); - cmc_assert_not_equals(ptr, NULL, hmm_get_ref(map, 1)); - cmc_assert(hmm_contains(map, 1)); - cmc_assert(hmm_resize(map, 1000)); - cmc_assert(hmm_resize(map, 100)); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 2, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - hmm_free(map); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); struct hashmultimap_fkey *hmm_fkey_numhash = &(struct hashmultimap_fkey){ diff --git a/tests/unt_hashmultiset.h b/tests/unt_hashmultiset.h index 92538b7..34bf646 100644 --- a/tests/unt_hashmultiset.h +++ b/tests/unt_hashmultiset.h @@ -331,94 +331,6 @@ CMC_CREATE_UNIT(CMCHashMultiSet, true, { hms_free(set); hms_free(set2); }); - - CMC_CREATE_TEST(callbacks, { - struct hashmultiset *set = hms_new_custom(100, 0.8, hms_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, set); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(hms_insert(set, 1)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(hms_insert_many(set, 1, 3)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(hms_update(set, 1, 0)); - cmc_assert_equals(int32_t, 1, total_update); - - cmc_assert(hms_update(set, 1, 10)); - cmc_assert_equals(int32_t, 2, total_update); - - cmc_assert(hms_remove(set, 1)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(hms_remove_all(set, 1)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(hms_update(set, 1, 10)); - cmc_assert_equals(int32_t, 3, total_update); - - cmc_assert(hms_max(set, NULL)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(hms_min(set, NULL)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(hms_contains(set, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert(hms_resize(set, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(hms_resize(set, 100)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 3, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - hms_customize(set, NULL, NULL); - - cmc_assert_equals(ptr, NULL, set->callbacks); - - hms_clear(set); - cmc_assert(hms_insert(set, 1)); - cmc_assert(hms_insert_many(set, 1, 3)); - cmc_assert(hms_update(set, 1, 0)); - cmc_assert(hms_update(set, 1, 10)); - cmc_assert(hms_remove(set, 1)); - cmc_assert(hms_remove_all(set, 1)); - cmc_assert(hms_update(set, 1, 10)); - cmc_assert(hms_max(set, NULL)); - cmc_assert(hms_min(set, NULL)); - cmc_assert(hms_contains(set, 1)); - cmc_assert(hms_resize(set, 1000)); - cmc_assert(hms_resize(set, 100)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 3, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, set->callbacks); - - hms_free(set); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); struct hashmultiset_fval *hms_fval_numhash = &(struct hashmultiset_fval){ diff --git a/tests/unt_hashset.h b/tests/unt_hashset.h index 61c084d..729c92c 100644 --- a/tests/unt_hashset.h +++ b/tests/unt_hashset.h @@ -547,78 +547,6 @@ CMC_CREATE_UNIT(CMCHashSet, true, { hs_free(set); hs_free(set2); }); - - CMC_CREATE_TEST(callbacks, { - struct hashset *set = hs_new_custom(100, 0.6, hs_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, set); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(hs_insert(set, 1)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(hs_remove(set, 1)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(hs_insert(set, 1)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(hs_max(set, NULL)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(hs_min(set, NULL)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(hs_contains(set, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert(hs_resize(set, 10000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(hs_resize(set, 500)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - hs_customize(set, NULL, NULL); - - cmc_assert_equals(ptr, NULL, set->callbacks); - - hs_clear(set); - cmc_assert(hs_resize(set, 10000)); - cmc_assert(hs_resize(set, 500)); - cmc_assert(hs_insert(set, 1)); - cmc_assert(hs_remove(set, 1)); - cmc_assert(hs_insert(set, 1)); - cmc_assert(hs_max(set, NULL)); - cmc_assert(hs_min(set, NULL)); - cmc_assert(hs_contains(set, 1)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, set->callbacks); - - hs_free(set); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); struct hashset_fval *hs_fval_numhash = &(struct hashset_fval){ diff --git a/tests/unt_heap.h b/tests/unt_heap.h index b2d79fd..e3c9dae 100644 --- a/tests/unt_heap.h +++ b/tests/unt_heap.h @@ -220,74 +220,6 @@ CMC_CREATE_UNIT(CMCHeap, true, { h_free(h); h_free(h2); }); - - CMC_CREATE_TEST(callbacks, { - struct heap *h = h_new_custom(100, CMC_MAX_HEAP, h_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, h); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(h_insert(h, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(h_remove(h)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(h_insert(h, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert_equals(size_t, 10, h_peek(h)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(h_contains(h, 10)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(h_resize(h, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(h_resize(h, 100)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 2, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - h_customize(h, NULL, NULL); - - cmc_assert_equals(ptr, NULL, h->callbacks); - - h_clear(h); - cmc_assert(h_insert(h, 10)); - cmc_assert(h_remove(h)); - cmc_assert(h_insert(h, 10)); - cmc_assert_equals(size_t, 10, h_peek(h)); - cmc_assert(h_contains(h, 10)); - cmc_assert(h_resize(h, 1000)); - cmc_assert(h_resize(h, 100)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 2, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, h->callbacks); - - h_free(h); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCHeapIter, true, { diff --git a/tests/unt_intervalheap.h b/tests/unt_intervalheap.h index 67d4a1b..7b16d37 100644 --- a/tests/unt_intervalheap.h +++ b/tests/unt_intervalheap.h @@ -214,7 +214,6 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { }); CMC_CREATE_TEST(PFX##_insert(), { - total_create = 0; struct intervalheap *ih = ih_new(100, ih_fval); cmc_assert_not_equals(ptr, NULL, ih); @@ -233,17 +232,6 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { ih_free(ih); - // callbacks - ih = ih_new_custom(100, ih_fval, NULL, callbacks); - - for (size_t i = 0; i < 10000; i++) - ih_insert(ih, i); - - cmc_assert_equals(size_t, 10000, ih_count(ih)); - cmc_assert_equals(int32_t, 10000, total_create); - - ih_free(ih); - // max ih = ih_new(1, ih_fval); @@ -289,11 +277,9 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { cmc_assert_equals(size_t, 1, ih->buffer[0][0]); ih_free(ih); - total_create = 0; }); CMC_CREATE_TEST(PFX##_remove_max(), { - total_delete = 0; struct intervalheap *ih = ih_new_custom(100, ih_fval, NULL, callbacks); // count == 0 @@ -306,7 +292,6 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { ih->flag = CMC_FLAG_ERROR; cmc_assert(ih_remove_max(ih)); - cmc_assert_equals(int32_t, 1, total_delete); cmc_assert_equals(int32_t, CMC_FLAG_OK, ih->flag); for (size_t i = 1; i <= 1000; i++) @@ -337,11 +322,9 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { } ih_free(ih); - total_delete = 0; }); CMC_CREATE_TEST(PFX##_remove_min(), { - total_delete = 0; struct intervalheap *ih = ih_new_custom(100, ih_fval, NULL, callbacks); // count == 0 @@ -354,7 +337,6 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { ih->flag = CMC_FLAG_ERROR; cmc_assert(ih_remove_min(ih)); - cmc_assert_equals(int32_t, 1, total_delete); cmc_assert_equals(int32_t, CMC_FLAG_OK, ih->flag); for (size_t i = 1000; i >= 1; i--) @@ -385,7 +367,6 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { } ih_free(ih); - total_delete = 0; }); CMC_CREATE_TEST(PFX##_remove_max() + PFX##_remove_min(), { @@ -521,96 +502,6 @@ CMC_CREATE_UNIT(CMCIntervalHeap, true, { ih_free(ih); ih_free(ih2); }); - - CMC_CREATE_TEST(callbacks, { - struct intervalheap *ih = ih_new_custom(100, ih_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, ih); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(ih_insert(ih, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(ih_remove_max(ih)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(ih_insert(ih, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(ih_remove_min(ih)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(ih_insert(ih, 1)); - cmc_assert(ih_insert(ih, 2)); - cmc_assert_equals(int32_t, 4, total_create); - - cmc_assert(ih_update_max(ih, 1)); - cmc_assert_equals(int32_t, 1, total_update); - - cmc_assert(ih_update_min(ih, 2)); - cmc_assert_equals(int32_t, 2, total_update); - - cmc_assert_equals(size_t, 2, ih_max(ih)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert_equals(size_t, 1, ih_min(ih)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(ih_contains(ih, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert(ih_resize(ih, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(ih_resize(ih, 50)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 2, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - ih_customize(ih, NULL, NULL); - - cmc_assert_equals(ptr, NULL, ih->callbacks); - - ih_clear(ih); - cmc_assert(ih_insert(ih, 10)); - cmc_assert(ih_remove_max(ih)); - cmc_assert(ih_insert(ih, 10)); - cmc_assert(ih_remove_min(ih)); - cmc_assert(ih_insert(ih, 1)); - cmc_assert(ih_insert(ih, 2)); - cmc_assert(ih_update_max(ih, 1)); - cmc_assert(ih_update_min(ih, 2)); - cmc_assert_equals(size_t, 2, ih_max(ih)); - cmc_assert_equals(size_t, 1, ih_min(ih)); - cmc_assert(ih_contains(ih, 1)); - cmc_assert(ih_resize(ih, 1000)); - cmc_assert(ih_resize(ih, 50)); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 2, total_update); - cmc_assert_equals(int32_t, 2, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, ih->callbacks); - - ih_free(ih); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCIntervalHeapIter, true, { diff --git a/tests/unt_linkedlist.h b/tests/unt_linkedlist.h index bdf2efb..cafb0e3 100644 --- a/tests/unt_linkedlist.h +++ b/tests/unt_linkedlist.h @@ -253,94 +253,6 @@ CMC_CREATE_UNIT(CMCLinkedList, true, { ll_free(ll); ll_free(ll2); }); - - CMC_CREATE_TEST(callbacks, { - struct linkedlist *ll = ll_new_custom(ll_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, ll); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(ll_push_front(ll, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(ll_push_back(ll, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(ll_push_at(ll, 10, 1)); - cmc_assert_equals(int32_t, 3, total_create); - - cmc_assert(ll_pop_at(ll, 1)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(ll_pop_front(ll)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(ll_pop_back(ll)); - cmc_assert_equals(int32_t, 3, total_delete); - - cmc_assert(ll_push_back(ll, 10)); - cmc_assert_equals(int32_t, 4, total_create); - - cmc_assert_equals(size_t, 10, ll_front(ll)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert_equals(size_t, 10, ll_back(ll)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert_equals(size_t, 10, ll_get(ll, 0)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_not_equals(ptr, NULL, ll_get_ref(ll, 0)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(ll_contains(ll, 10)); - cmc_assert_equals(int32_t, 5, total_read); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 3, total_delete); - cmc_assert_equals(int32_t, 0, total_resize); - - ll_customize(ll, NULL, NULL); - - cmc_assert_equals(ptr, NULL, ll->callbacks); - - ll_clear(ll); - cmc_assert(ll_push_front(ll, 10)); - cmc_assert(ll_push_back(ll, 10)); - cmc_assert(ll_push_at(ll, 10, 1)); - cmc_assert(ll_pop_at(ll, 1)); - cmc_assert(ll_pop_front(ll)); - cmc_assert(ll_pop_back(ll)); - cmc_assert(ll_push_back(ll, 10)); - cmc_assert_equals(size_t, 10, ll_front(ll)); - cmc_assert_equals(size_t, 10, ll_back(ll)); - cmc_assert_equals(size_t, 10, ll_get(ll, 0)); - cmc_assert_not_equals(ptr, NULL, ll_get_ref(ll, 0)); - cmc_assert(ll_contains(ll, 10)); - - cmc_assert_equals(int32_t, 4, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 3, total_delete); - cmc_assert_equals(int32_t, 0, total_resize); - - cmc_assert_equals(ptr, NULL, ll->callbacks); - - ll_free(ll); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCLinkedListIter, true, { diff --git a/tests/unt_list.h b/tests/unt_list.h index 080038a..a605f92 100644 --- a/tests/unt_list.h +++ b/tests/unt_list.h @@ -494,124 +494,6 @@ CMC_CREATE_UNIT(CMCList, true, { l_free(l2); l_free(l3); }); - - CMC_CREATE_TEST(callbacks, { - struct list *l = l_new_custom(100, l_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, l); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(l_push_front(l, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(l_push_back(l, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(l_push_at(l, 10, 1)); - cmc_assert_equals(int32_t, 3, total_create); - - cmc_assert(l_pop_at(l, 1)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(l_pop_front(l)); - cmc_assert_equals(int32_t, 2, total_delete); - - cmc_assert(l_pop_back(l)); - cmc_assert_equals(int32_t, 3, total_delete); - - cmc_assert(l_push_back(l, 10)); - cmc_assert_equals(int32_t, 4, total_create); - - cmc_assert_equals(size_t, 10, l_front(l)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert_equals(size_t, 10, l_back(l)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert_equals(size_t, 10, l_get(l, 0)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_not_equals(ptr, NULL, l_get_ref(l, 0)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(l_contains(l, 10)); - cmc_assert_equals(int32_t, 5, total_read); - - cmc_assert(l_seq_push_front(l, (size_t[]){ 7, 8, 9 }, 3)); - cmc_assert_equals(int32_t, 5, total_create); - - cmc_assert(l_seq_push_back(l, (size_t[]){ 14, 15, 16 }, 3)); - cmc_assert_equals(int32_t, 6, total_create); - - cmc_assert(l_seq_push_at(l, (size_t[]){ 11, 12, 13 }, 3, 4)); - cmc_assert_equals(int32_t, 7, total_create); - - cmc_assert(l_seq_pop_at(l, 1, 4)); - cmc_assert_equals(int32_t, 4, total_delete); - - struct list *l2 = l_seq_sublist(l, 0, 4); - cmc_assert_equals(int32_t, 5, total_delete); - - cmc_assert(l_resize(l, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(l_resize(l2, 1000)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 7, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 5, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - l_customize(l, NULL, NULL); - - cmc_assert_equals(ptr, NULL, l->callbacks); - - l_clear(l); - cmc_assert(l_push_front(l, 10)); - cmc_assert(l_push_back(l, 10)); - cmc_assert(l_push_at(l, 10, 1)); - cmc_assert(l_pop_at(l, 1)); - cmc_assert(l_pop_front(l)); - cmc_assert(l_pop_back(l)); - cmc_assert(l_push_back(l, 10)); - cmc_assert_equals(size_t, 10, l_front(l)); - cmc_assert_equals(size_t, 10, l_back(l)); - cmc_assert_equals(size_t, 10, l_get(l, 0)); - cmc_assert_not_equals(ptr, NULL, l_get_ref(l, 0)); - cmc_assert(l_contains(l, 10)); - cmc_assert(l_seq_push_front(l, (size_t[]){ 7, 8, 9 }, 3)); - cmc_assert(l_seq_push_back(l, (size_t[]){ 14, 15, 16 }, 3)); - cmc_assert(l_seq_push_at(l, (size_t[]){ 11, 12, 13 }, 3, 4)); - cmc_assert(l_seq_pop_at(l, 1, 4)); - struct list *l3 = l_seq_sublist(l, 0, 4); - cmc_assert(l_resize(l, 1000)); - cmc_assert(l_resize(l3, 1000)); - - cmc_assert_equals(int32_t, 7, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 5, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, l->callbacks); - - l_free(l); - l_free(l2); - l_free(l3); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }) CMC_CREATE_UNIT(CMCListIter, true, { diff --git a/tests/unt_queue.h b/tests/unt_queue.h index 9f58648..72fe0f7 100644 --- a/tests/unt_queue.h +++ b/tests/unt_queue.h @@ -472,74 +472,6 @@ CMC_CREATE_UNIT(CMCQueue, true, { q_free(q); q_free(q2); }); - - CMC_CREATE_TEST(callbacks, { - struct queue *q = q_new_custom(100, q_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, q); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(q_enqueue(q, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(q_dequeue(q)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(q_enqueue(q, 10)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert_equals(size_t, 10, q_peek(q)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(q_contains(q, 10)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(q_resize(q, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(q_resize(q, 100)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 2, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - q_customize(q, NULL, NULL); - - cmc_assert_equals(ptr, NULL, q->callbacks); - - q_clear(q); - cmc_assert(q_enqueue(q, 10)); - cmc_assert(q_dequeue(q)); - cmc_assert(q_enqueue(q, 10)); - cmc_assert_equals(size_t, 10, q_peek(q)); - cmc_assert(q_contains(q, 10)); - cmc_assert(q_resize(q, 1000)); - cmc_assert(q_resize(q, 100)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 2, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, q->callbacks); - - q_free(q); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCQueueIter, true, { diff --git a/tests/unt_sortedlist.h b/tests/unt_sortedlist.h index 12630a8..0b2b7bd 100644 --- a/tests/unt_sortedlist.h +++ b/tests/unt_sortedlist.h @@ -232,84 +232,6 @@ CMC_CREATE_UNIT(CMCSortedList, true, { sl_free(sl); sl_free(sl2); }); - - CMC_CREATE_TEST(callbacks, { - struct sortedlist *sl = sl_new_custom(100, sl_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, sl); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(sl_insert(sl, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(sl_remove(sl, 0)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(sl_insert(sl, 1)); - cmc_assert(sl_insert(sl, 0)); - cmc_assert_equals(int32_t, 3, total_create); - - cmc_assert_equals(size_t, 1, sl_max(sl)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert_equals(size_t, 0, sl_min(sl)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert_equals(size_t, 0, sl_get(sl, 0)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_equals(size_t, 0, sl_index_of(sl, 0, true)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(sl_contains(sl, 1)); - cmc_assert_equals(int32_t, 5, total_read); - - cmc_assert(sl_resize(sl, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(sl_resize(sl, 50)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 3, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - sl_customize(sl, NULL, NULL); - - sl_clear(sl); - cmc_assert(sl_insert(sl, 10)); - cmc_assert(sl_remove(sl, 0)); - cmc_assert(sl_insert(sl, 1)); - cmc_assert(sl_insert(sl, 0)); - cmc_assert_equals(size_t, 1, sl_max(sl)); - cmc_assert_equals(size_t, 0, sl_min(sl)); - cmc_assert_equals(size_t, 0, sl_get(sl, 0)); - cmc_assert_equals(size_t, 0, sl_index_of(sl, 0, true)); - cmc_assert(sl_contains(sl, 1)); - - cmc_assert_equals(int32_t, 3, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, sl->callbacks); - - sl_free(sl); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCSortedListIter, true, { diff --git a/tests/unt_stack.h b/tests/unt_stack.h index 8756ff3..4aeadbc 100644 --- a/tests/unt_stack.h +++ b/tests/unt_stack.h @@ -338,72 +338,6 @@ CMC_CREATE_UNIT(CMCStack, true, { s_free(s); s_free(s2); }); - - CMC_CREATE_TEST(callbacks, { - struct stack *s = s_new_custom(100, s_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, s); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(s_push(s, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(s_pop(s)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(s_push(s, 1)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert_equals(size_t, 1, s_top(s)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(s_contains(s, 1)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(s_resize(s, 1000)); - cmc_assert_equals(int32_t, 1, total_resize); - - cmc_assert(s_resize(s, 10)); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 2, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - s_customize(s, NULL, NULL); - - s_clear(s); - cmc_assert(s_push(s, 10)); - cmc_assert(s_pop(s)); - cmc_assert(s_push(s, 1)); - cmc_assert_equals(size_t, 1, s_top(s)); - cmc_assert(s_contains(s, 1)); - cmc_assert(s_resize(s, 1000)); - cmc_assert(s_resize(s, 10)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 2, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 2, total_resize); - - cmc_assert_equals(ptr, NULL, s->callbacks); - - s_free(s); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - }); }); CMC_CREATE_UNIT(CMCStackIter, true, { diff --git a/tests/unt_treemap.h b/tests/unt_treemap.h index f28f63a..35dbb59 100644 --- a/tests/unt_treemap.h +++ b/tests/unt_treemap.h @@ -139,80 +139,6 @@ CMC_CREATE_UNIT(CMCTreeMap, true, { tm_free(map); tm_free(map2); }); - - CMC_CREATE_TEST(callbacks, { - struct treemap *map = tm_new_custom(tm_fkey, tm_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, map); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(tm_insert(map, 1, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(tm_update(map, 1, 2, NULL)); - cmc_assert_equals(int32_t, 1, total_update); - - cmc_assert(tm_remove(map, 1, NULL)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(tm_insert(map, 1, 2)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(tm_max(map, NULL, NULL)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(tm_min(map, NULL, NULL)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert_equals(size_t, 2, tm_get(map, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_not_equals(ptr, NULL, tm_get_ref(map, 1)); - cmc_assert_equals(int32_t, 4, total_read); - - cmc_assert(tm_contains(map, 1)); - cmc_assert_equals(int32_t, 5, total_read); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 1, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 0, total_resize); - - tm_customize(map, NULL, NULL); - - tm_clear(map); - cmc_assert(tm_insert(map, 1, 10)); - cmc_assert(tm_update(map, 1, 2, NULL)); - cmc_assert(tm_remove(map, 1, NULL)); - cmc_assert(tm_insert(map, 1, 2)); - cmc_assert(tm_max(map, NULL, NULL)); - cmc_assert(tm_min(map, NULL, NULL)); - cmc_assert_equals(size_t, 2, tm_get(map, 1)); - cmc_assert_not_equals(ptr, NULL, tm_get_ref(map, 1)); - cmc_assert(tm_contains(map, 1)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 5, total_read); - cmc_assert_equals(int32_t, 1, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 0, total_resize); - - cmc_assert_equals(ptr, NULL, map->callbacks); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - tm_free(map); - }); }); CMC_CREATE_UNIT(CMCTreeMapIter, true, { diff --git a/tests/unt_treeset.h b/tests/unt_treeset.h index 0f26c66..ba208e6 100644 --- a/tests/unt_treeset.h +++ b/tests/unt_treeset.h @@ -102,68 +102,6 @@ CMC_CREATE_UNIT(CMCTreeSet, true, { ts_free(set); ts_free(set2); }); - - CMC_CREATE_TEST(callbacks, { - struct treeset *set = ts_new_custom(ts_fval, NULL, callbacks); - - cmc_assert_not_equals(ptr, NULL, set); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - cmc_assert(ts_insert(set, 10)); - cmc_assert_equals(int32_t, 1, total_create); - - cmc_assert(ts_remove(set, 10)); - cmc_assert_equals(int32_t, 1, total_delete); - - cmc_assert(ts_insert(set, 1)); - cmc_assert_equals(int32_t, 2, total_create); - - cmc_assert(ts_max(set, NULL)); - cmc_assert_equals(int32_t, 1, total_read); - - cmc_assert(ts_min(set, NULL)); - cmc_assert_equals(int32_t, 2, total_read); - - cmc_assert(ts_contains(set, 1)); - cmc_assert_equals(int32_t, 3, total_read); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 0, total_resize); - - ts_customize(set, NULL, NULL); - - ts_clear(set); - cmc_assert(ts_insert(set, 10)); - cmc_assert(ts_remove(set, 10)); - cmc_assert(ts_insert(set, 1)); - cmc_assert(ts_max(set, NULL)); - cmc_assert(ts_min(set, NULL)); - cmc_assert(ts_contains(set, 1)); - - cmc_assert_equals(int32_t, 2, total_create); - cmc_assert_equals(int32_t, 3, total_read); - cmc_assert_equals(int32_t, 0, total_update); - cmc_assert_equals(int32_t, 1, total_delete); - cmc_assert_equals(int32_t, 0, total_resize); - - cmc_assert_equals(ptr, NULL, set->callbacks); - - total_create = 0; - total_read = 0; - total_update = 0; - total_delete = 0; - total_resize = 0; - - ts_free(set); - }); }); CMC_CREATE_UNIT(CMCTreeSetIter, true, { diff --git a/tests/utl.h b/tests/utl.h index 2645acd..cf670e4 100644 --- a/tests/utl.h +++ b/tests/utl.h @@ -129,43 +129,9 @@ int v_c_pri(size_t a, size_t b) return (a > b) - (a < b); } -// callbacks - -int total_create = 0; -int total_read = 0; -int total_update = 0; -int total_delete = 0; -int total_resize = 0; - -void callback_create(void) +void callbacks(CMC_UNUSED const char func_name[], CMC_UNUSED void *self) { - total_create++; + // EMPTY for now.. } -void callback_read(void) -{ - total_read++; -} - -void callback_update(void) -{ - total_update++; -} - -void callback_delete(void) -{ - total_delete++; -} - -void callback_resize(void) -{ - total_resize++; -} - -struct cmc_callbacks *callbacks = &(struct cmc_callbacks){ .create = callback_create, - .read = callback_read, - .update = callback_update, - .delete = callback_delete, - .resize = callback_resize }; - #endif /* CMC_TESTS_UTL */