diff --git a/src/cmc/deque.h b/src/cmc/deque.h index 0cb968d..9928836 100644 --- a/src/cmc/deque.h +++ b/src/cmc/deque.h @@ -147,16 +147,6 @@ static const char *cmc_string_fmt_deque = "%s at %p { buffer:%p, capacity:%" PRI V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_DEQUE_SOURCE(PFX, SNAME, V) \ \ @@ -269,7 +259,7 @@ static const char *cmc_string_fmt_deque = "%s at %p { buffer:%p, capacity:%" PRI if (PFX##_empty(_deque_)) \ return false; \ \ - _deque_->buffer[_deque_->front] = PFX##_impl_default_value(); \ + _deque_->buffer[_deque_->front] = (V){0}; \ \ _deque_->front = (_deque_->front == _deque_->capacity - 1) ? 0 : _deque_->front + 1; \ \ @@ -285,7 +275,7 @@ static const char *cmc_string_fmt_deque = "%s at %p { buffer:%p, capacity:%" PRI \ _deque_->back = (_deque_->back == 0) ? _deque_->capacity - 1 : _deque_->back - 1; \ \ - _deque_->buffer[_deque_->back] = PFX##_impl_default_value(); \ + _deque_->buffer[_deque_->back] = (V){0}; \ \ _deque_->count--; \ \ @@ -295,7 +285,7 @@ static const char *cmc_string_fmt_deque = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_front(SNAME *_deque_) \ { \ if (PFX##_empty(_deque_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _deque_->buffer[_deque_->front]; \ } \ @@ -303,7 +293,7 @@ static const char *cmc_string_fmt_deque = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_back(SNAME *_deque_) \ { \ if (PFX##_empty(_deque_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _deque_->buffer[(_deque_->back == 0) ? _deque_->capacity - 1 : _deque_->back - 1]; \ } \ @@ -603,7 +593,7 @@ static const char *cmc_string_fmt_deque = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor]; \ } \ diff --git a/src/cmc/hashmap.h b/src/cmc/hashmap.h index 797a3e6..9bba615 100644 --- a/src/cmc/hashmap.h +++ b/src/cmc/hashmap.h @@ -214,26 +214,6 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Key */ \ - static inline K PFX##_impl_default_key(void) \ - { \ - K _empty_key_; \ - \ - memset(&_empty_key_, 0, sizeof(K)); \ - \ - return _empty_key_; \ - } \ - \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_HASHMAP_SOURCE(PFX, SNAME, K, V) \ \ @@ -407,8 +387,8 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, if (out_value) \ *out_value = result->value; \ \ - result->key = PFX##_impl_default_key(); \ - result->value = PFX##_impl_default_value(); \ + result->key = (K){0}; \ + result->value = (V){0}; \ result->dist = 0; \ result->state = CMC_ES_DELETED; \ \ @@ -488,7 +468,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, SNAME##_entry *entry = PFX##_impl_get_entry(_map_, key); \ \ if (!entry) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return entry->value; \ } \ @@ -866,7 +846,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, K PFX##_iter_key(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_key(); \ + return (K){0}; \ \ return iter->target->buffer[iter->cursor].key; \ } \ @@ -874,7 +854,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor].value; \ } \ diff --git a/src/cmc/hashset.h b/src/cmc/hashset.h index 4471a5f..a89fea3 100644 --- a/src/cmc/hashset.h +++ b/src/cmc/hashset.h @@ -214,16 +214,6 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_HASHSET_SOURCE(PFX, SNAME, V) \ \ @@ -374,7 +364,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, if (result == NULL) \ return false; \ \ - result->value = PFX##_impl_default_value(); \ + result->value = (V){0}; \ result->dist = 0; \ result->state = CMC_ES_DELETED; \ \ @@ -978,7 +968,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor].value; \ } \ diff --git a/src/cmc/heap.h b/src/cmc/heap.h index 611b35e..06693a8 100644 --- a/src/cmc/heap.h +++ b/src/cmc/heap.h @@ -145,16 +145,6 @@ typedef enum cmc_heap_order_e V PFX##_iter_value(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_HEAP_SOURCE(PFX, SNAME, V) \ \ @@ -256,7 +246,7 @@ typedef enum cmc_heap_order_e \ *result = _heap_->buffer[0]; \ _heap_->buffer[0] = _heap_->buffer[_heap_->count - 1]; \ - _heap_->buffer[_heap_->count - 1] = PFX##_impl_default_value(); \ + _heap_->buffer[_heap_->count - 1] = (V){0}; \ \ _heap_->count--; \ \ @@ -269,7 +259,7 @@ typedef enum cmc_heap_order_e V PFX##_peek(SNAME *_heap_) \ { \ if (PFX##_empty(_heap_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _heap_->buffer[0]; \ } \ @@ -526,7 +516,7 @@ typedef enum cmc_heap_order_e V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor]; \ } \ diff --git a/src/cmc/linkedlist.h b/src/cmc/linkedlist.h index 3c373e1..af89c76 100644 --- a/src/cmc/linkedlist.h +++ b/src/cmc/linkedlist.h @@ -172,16 +172,6 @@ static const char *cmc_string_fmt_linkedlist = "%s at %p { count:%" PRIuMAX ", h size_t PFX##_iter_index(SNAME##_iter *iter); \ SNAME##_node *PFX##_iter_node(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_LINKEDLIST_SOURCE(PFX, SNAME, V) \ \ @@ -390,7 +380,7 @@ static const char *cmc_string_fmt_linkedlist = "%s at %p { count:%" PRIuMAX ", h V PFX##_front(SNAME *_list_) \ { \ if (PFX##_empty(_list_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _list_->head->data; \ } \ @@ -398,12 +388,12 @@ static const char *cmc_string_fmt_linkedlist = "%s at %p { count:%" PRIuMAX ", h V PFX##_get(SNAME *_list_, size_t index) \ { \ if (index >= _list_->count || PFX##_empty(_list_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ SNAME##_node *scan = PFX##_get_node(_list_, index); \ \ if (scan == NULL) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return scan->data; \ } \ @@ -427,7 +417,7 @@ static const char *cmc_string_fmt_linkedlist = "%s at %p { count:%" PRIuMAX ", h V PFX##_back(SNAME *_list_) \ { \ if (PFX##_empty(_list_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _list_->tail->data; \ } \ @@ -869,7 +859,7 @@ static const char *cmc_string_fmt_linkedlist = "%s at %p { count:%" PRIuMAX ", h V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->cursor->data; \ } \ diff --git a/src/cmc/list.h b/src/cmc/list.h index 0c01f8a..09425a0 100644 --- a/src/cmc/list.h +++ b/src/cmc/list.h @@ -163,16 +163,6 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_LIST_SOURCE(PFX, SNAME, V) \ \ @@ -311,7 +301,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu \ memmove(_list_->buffer, _list_->buffer + 1, _list_->count * sizeof(V)); \ \ - _list_->buffer[--_list_->count] = PFX##_impl_default_value(); \ + _list_->buffer[--_list_->count] = (V){0}; \ \ return true; \ } \ @@ -324,7 +314,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu memmove(_list_->buffer + index, _list_->buffer + index + 1, \ (_list_->count - index) * sizeof(V)); \ \ - _list_->buffer[--_list_->count] = PFX##_impl_default_value(); \ + _list_->buffer[--_list_->count] = (V){0}; \ \ return true; \ } \ @@ -334,7 +324,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu if (PFX##_empty(_list_)) \ return false; \ \ - _list_->buffer[--_list_->count] = PFX##_impl_default_value(); \ + _list_->buffer[--_list_->count] = (V){0}; \ \ return true; \ } \ @@ -450,7 +440,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu V PFX##_front(SNAME *_list_) \ { \ if (PFX##_empty(_list_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _list_->buffer[0]; \ } \ @@ -458,7 +448,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu V PFX##_get(SNAME *_list_, size_t index) \ { \ if (index >= _list_->count || PFX##_empty(_list_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _list_->buffer[index]; \ } \ @@ -477,7 +467,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu V PFX##_back(SNAME *_list_) \ { \ if (PFX##_empty(_list_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _list_->buffer[_list_->count - 1]; \ } \ @@ -757,7 +747,7 @@ static const char *cmc_string_fmt_list = "%s at %p { buffer:%p, capacity:%" PRIu V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor]; \ } \ diff --git a/src/cmc/queue.h b/src/cmc/queue.h index a43feba..4fdf2ff 100644 --- a/src/cmc/queue.h +++ b/src/cmc/queue.h @@ -156,16 +156,6 @@ static const char *cmc_string_fmt_queue = "%s at %p { buffer:%p, capacity:%" PRI V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_QUEUE_SOURCE(PFX, SNAME, V) \ \ @@ -260,7 +250,7 @@ static const char *cmc_string_fmt_queue = "%s at %p { buffer:%p, capacity:%" PRI if (PFX##_empty(_queue_)) \ return false; \ \ - _queue_->buffer[_queue_->front] = PFX##_impl_default_value(); \ + _queue_->buffer[_queue_->front] = (V){0}; \ \ _queue_->front = (_queue_->front == _queue_->capacity - 1) ? 0 : _queue_->front + 1; \ _queue_->count--; \ @@ -271,7 +261,7 @@ static const char *cmc_string_fmt_queue = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_peek(SNAME *_queue_) \ { \ if (PFX##_empty(_queue_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _queue_->buffer[_queue_->front]; \ } \ @@ -567,7 +557,7 @@ static const char *cmc_string_fmt_queue = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor]; \ } \ diff --git a/src/cmc/stack.h b/src/cmc/stack.h index caa3f76..50a0b49 100644 --- a/src/cmc/stack.h +++ b/src/cmc/stack.h @@ -132,16 +132,6 @@ static const char *cmc_string_fmt_stack = "%s at %p { buffer:%p, capacity:%" PRI V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_STACK_SOURCE(PFX, SNAME, V) \ \ @@ -221,7 +211,7 @@ static const char *cmc_string_fmt_stack = "%s at %p { buffer:%p, capacity:%" PRI if (PFX##_empty(_stack_)) \ return false; \ \ - _stack_->buffer[--_stack_->count] = PFX##_impl_default_value(); \ + _stack_->buffer[--_stack_->count] = (V){0}; \ \ return true; \ } \ @@ -229,7 +219,7 @@ static const char *cmc_string_fmt_stack = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_top(SNAME *_stack_) \ { \ if (PFX##_empty(_stack_)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return _stack_->buffer[_stack_->count - 1]; \ } \ @@ -483,7 +473,7 @@ static const char *cmc_string_fmt_stack = "%s at %p { buffer:%p, capacity:%" PRI V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor]; \ } \ diff --git a/src/cmc/treemap.h b/src/cmc/treemap.h index 9366db7..38d3db4 100644 --- a/src/cmc/treemap.h +++ b/src/cmc/treemap.h @@ -157,26 +157,6 @@ static const char *cmc_string_fmt_treemap = "%s at %p { root:%p, count:%" PRIuMA V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Key */ \ - static inline K PFX##_impl_default_key(void) \ - { \ - K _empty_key_; \ - \ - memset(&_empty_key_, 0, sizeof(K)); \ - \ - return _empty_key_; \ - } \ - \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_TREEMAP_SOURCE(PFX, SNAME, K, V) \ \ @@ -511,7 +491,7 @@ static const char *cmc_string_fmt_treemap = "%s at %p { root:%p, count:%" PRIuMA SNAME##_node *node = PFX##_impl_get_node(_map_, key); \ \ if (!node) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return node->value; \ } \ @@ -834,7 +814,7 @@ static const char *cmc_string_fmt_treemap = "%s at %p { root:%p, count:%" PRIuMA K PFX##_iter_key(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_key(); \ + return (K){0}; \ \ return iter->cursor->key; \ } \ @@ -842,7 +822,7 @@ static const char *cmc_string_fmt_treemap = "%s at %p { root:%p, count:%" PRIuMA V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->cursor->value; \ } \ diff --git a/src/cmc/treeset.h b/src/cmc/treeset.h index b802702..86af1e5 100644 --- a/src/cmc/treeset.h +++ b/src/cmc/treeset.h @@ -977,7 +977,7 @@ static const char *cmc_string_fmt_treeset = "%s at %p { root:%p, count:%" PRIuMA V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->cursor->value; \ } \ diff --git a/src/ext/bidimap.h b/src/ext/bidimap.h index 0b06788..552f10f 100644 --- a/src/ext/bidimap.h +++ b/src/ext/bidimap.h @@ -223,26 +223,6 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Key */ \ - static inline K PFX##_impl_default_key(void) \ - { \ - K _empty_key_; \ - \ - memset(&_empty_key_, 0, sizeof(K)); \ - \ - return _empty_key_; \ - } \ - \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_BIDIMAP_SOURCE(PFX, SNAME, K, V) \ \ @@ -401,7 +381,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, SNAME##_entry **entry = PFX##_impl_get_entry_by_val(_map_, val); \ \ if (!entry) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return (*entry)->key; \ } \ @@ -411,7 +391,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, SNAME##_entry **entry = PFX##_impl_get_entry_by_key(_map_, key); \ \ if (!entry) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return (*entry)->value; \ } \ @@ -676,7 +656,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, K PFX##_iter_key(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_key(); \ + return (K){0}; \ \ return iter->target->key_buffer[iter->cursor]->key; \ } \ @@ -684,7 +664,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->key_buffer[iter->cursor]->value; \ } \ @@ -696,6 +676,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, \ static bool PFX##_impl_grow(SNAME *_map_) \ { \ + /* TODO */ \ return false; \ } \ \ diff --git a/src/ext/intervalheap.h b/src/ext/intervalheap.h index 4493428..77289c8 100644 --- a/src/ext/intervalheap.h +++ b/src/ext/intervalheap.h @@ -144,16 +144,6 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity V PFX##_iter_value(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_INTERVALHEAP_SOURCE(PFX, SNAME, V) \ \ @@ -243,7 +233,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity { \ /* Occupying a new node */ \ _heap_->buffer[_heap_->size].data[0] = element; \ - _heap_->buffer[_heap_->size].data[1] = PFX##_impl_default_value(); \ + _heap_->buffer[_heap_->size].data[1] = (V){0}; \ \ _heap_->size++; \ } \ @@ -291,7 +281,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity { \ *result = _heap_->buffer[0].data[0]; \ \ - _heap_->buffer[0].data[0] = PFX##_impl_default_value(); \ + _heap_->buffer[0].data[0] = (V){0}; \ \ _heap_->count--; \ \ @@ -308,7 +298,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity /* Grab from MinHeap and discard last node */ \ _heap_->buffer[0].data[1] = last_node->data[0]; \ \ - last_node->data[0] = PFX##_impl_default_value(); \ + last_node->data[0] = (V){0}; \ \ _heap_->size--; \ } \ @@ -316,7 +306,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity { \ _heap_->buffer[0].data[1] = last_node->data[1]; \ \ - last_node->data[1] = PFX##_impl_default_value(); \ + last_node->data[1] = (V){0}; \ } \ \ _heap_->count--; \ @@ -336,7 +326,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity \ if (PFX##_count(_heap_) == 1) \ { \ - _heap_->buffer[0].data[0] = PFX##_impl_default_value(); \ + _heap_->buffer[0].data[0] = (V){0}; \ \ _heap_->count--; \ \ @@ -351,7 +341,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity if (PFX##_count(_heap_) % 2 == 1) \ { \ /* Discard last node */ \ - last_node->data[0] = PFX##_impl_default_value(); \ + last_node->data[0] = (V){0}; \ \ _heap_->size--; \ } \ @@ -359,7 +349,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity { \ /* Place the MaxHeap value in the MinHeap value spot */ \ last_node->data[0] = last_node->data[1]; \ - last_node->data[1] = PFX##_impl_default_value(); \ + last_node->data[1] = (V){0}; \ } \ \ _heap_->count--; \ @@ -717,7 +707,7 @@ static const char *cmc_string_fmt_intervalheap = "%s at %p { buffer:%p, capacity V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor / 2].data[iter->cursor % 2]; \ } \ diff --git a/src/ext/multimap.h b/src/ext/multimap.h index 07df95e..4a917f3 100644 --- a/src/ext/multimap.h +++ b/src/ext/multimap.h @@ -230,26 +230,6 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V *PFX##_iter_rvalue(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Key */ \ - static inline K PFX##_impl_default_key(void) \ - { \ - K _empty_key_; \ - \ - memset(&_empty_key_, 0, sizeof(K)); \ - \ - return _empty_key_; \ - } \ - \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_MULTIMAP_SOURCE(PFX, SNAME, K, V) \ \ @@ -647,7 +627,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, SNAME##_entry *entry = PFX##_impl_get_entry(_map_, key); \ \ if (!entry) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return entry->value; \ } \ @@ -1051,7 +1031,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, K PFX##_iter_key(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_key(); \ + return (K){0}; \ \ return iter->curr_entry->key; \ } \ @@ -1059,7 +1039,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->curr_entry->value; \ } \ diff --git a/src/ext/multiset.h b/src/ext/multiset.h index 55154c8..e072e59 100644 --- a/src/ext/multiset.h +++ b/src/ext/multiset.h @@ -230,16 +230,6 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, size_t PFX##_iter_multiplicity(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_MULTISET_SOURCE(PFX, SNAME, V) \ \ @@ -400,7 +390,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, result->multiplicity--; \ else \ { \ - result->value = PFX##_impl_default_value(); \ + result->value = (V){0}; \ result->multiplicity = 0; \ result->dist = 0; \ result->state = CMC_ES_DELETED; \ @@ -422,7 +412,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, \ size_t removed = result->multiplicity; \ \ - result->value = PFX##_impl_default_value(); \ + result->value = (V){0}; \ result->multiplicity = 0; \ result->dist = 0; \ result->state = CMC_ES_DELETED; \ @@ -1093,7 +1083,7 @@ static const size_t cmc_hashtable_primes[] = {53, 97, 191, 383, 769, 1531, V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor].value; \ } \ diff --git a/src/ext/sortedlist.h b/src/ext/sortedlist.h index 9c5289e..3dc4491 100644 --- a/src/ext/sortedlist.h +++ b/src/ext/sortedlist.h @@ -136,16 +136,6 @@ static const char *cmc_string_fmt_sortedlist = "%s at %p { buffer:%p, capacity:% V PFX##_iter_value(SNAME##_iter *iter); \ size_t PFX##_iter_index(SNAME##_iter *iter); \ \ - /* Default Value */ \ - static inline V PFX##_impl_default_value(void) \ - { \ - V _empty_value_; \ - \ - memset(&_empty_value_, 0, sizeof(V)); \ - \ - return _empty_value_; \ - } \ - \ /* SOURCE ********************************************************************/ #define CMC_GENERATE_SORTEDLIST_SOURCE(PFX, SNAME, V) \ \ @@ -234,7 +224,7 @@ static const char *cmc_string_fmt_sortedlist = "%s at %p { buffer:%p, capacity:% memmove(_list_->buffer + index, _list_->buffer + index + 1, \ (_list_->count - index) * sizeof(V)); \ \ - _list_->buffer[--_list_->count] = PFX##_impl_default_value(); \ + _list_->buffer[--_list_->count] = (V){0}; \ \ return true; \ } \ @@ -266,7 +256,7 @@ static const char *cmc_string_fmt_sortedlist = "%s at %p { buffer:%p, capacity:% V PFX##_get(SNAME *_list_, size_t index) \ { \ if (index >= _list_->count) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ PFX##_sort(_list_); \ \ @@ -545,7 +535,7 @@ static const char *cmc_string_fmt_sortedlist = "%s at %p { buffer:%p, capacity:% V PFX##_iter_value(SNAME##_iter *iter) \ { \ if (PFX##_empty(iter->target)) \ - return PFX##_impl_default_value(); \ + return (V){0}; \ \ return iter->target->buffer[iter->cursor]; \ } \ diff --git a/tests/main/unt/deque.c b/tests/main/unt/deque.c index 4b65f55..dfc386d 100644 --- a/tests/main/unt/deque.c +++ b/tests/main/unt/deque.c @@ -307,7 +307,7 @@ CMC_CREATE_UNIT(deque_test, true, { size_t r = d_front(d); - cmc_assert_equals(size_t, d_impl_default_value(), r); + cmc_assert_equals(size_t, (size_t){0}, r); d_free(d, NULL); }); @@ -348,7 +348,7 @@ CMC_CREATE_UNIT(deque_test, true, { size_t r = d_back(d); - cmc_assert_equals(size_t, d_impl_default_value(), r); + cmc_assert_equals(size_t, (size_t){0}, r); d_free(d, NULL); }); diff --git a/tests/main/unt/hashmap.c b/tests/main/unt/hashmap.c index 1ac5415..3f06d7c 100644 --- a/tests/main/unt/hashmap.c +++ b/tests/main/unt/hashmap.c @@ -304,7 +304,7 @@ CMC_CREATE_UNIT(hashmap_test, true, { cmc_assert_not_equals(ptr, NULL, map); - cmc_assert_equals(size_t, hm_impl_default_value(), hm_get(map, 4321)); + cmc_assert_equals(size_t, (size_t){0}, hm_get(map, 4321)); hm_free(map, NULL); }); diff --git a/tests/main/unt/heap.c b/tests/main/unt/heap.c index 8eebd44..b7715e5 100644 --- a/tests/main/unt/heap.c +++ b/tests/main/unt/heap.c @@ -157,7 +157,7 @@ CMC_CREATE_UNIT(heap_test, true, { cmc_assert_not_equals(ptr, NULL, h); - cmc_assert_equals(size_t, h_impl_default_value(), h_peek(h)); + cmc_assert_equals(size_t, (size_t){0}, h_peek(h)); h_free(h, NULL); }); diff --git a/tests/main/unt/queue.c b/tests/main/unt/queue.c index 5d6c296..f069b8b 100644 --- a/tests/main/unt/queue.c +++ b/tests/main/unt/queue.c @@ -165,7 +165,7 @@ CMC_CREATE_UNIT(queue_test, true, { size_t r = q_peek(q); - cmc_assert_equals(size_t, q_impl_default_value(), r); + cmc_assert_equals(size_t, (size_t){0}, r); q_free(q, NULL); }); diff --git a/tests/main/unt/stack.c b/tests/main/unt/stack.c index e9df04b..963f550 100644 --- a/tests/main/unt/stack.c +++ b/tests/main/unt/stack.c @@ -186,7 +186,7 @@ CMC_CREATE_UNIT(stack_test, true, { cmc_assert(s_pop(s)); - cmc_assert_equals(size_t, s_impl_default_value(), s_top(s)); + cmc_assert_equals(size_t, (size_t){0}, s_top(s)); s_free(s, NULL); }); @@ -526,7 +526,7 @@ CMC_CREATE_UNIT(stack_test, true, { s_iter_init(&iter, s); - cmc_assert_equals(size_t, s_impl_default_value(), s_iter_value(&iter)); + cmc_assert_equals(size_t, (size_t){0}, s_iter_value(&iter)); s_free(s, NULL); });