From 1cf7c4fa4d3c9d718b2da61e6dd437b256badf29 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 16 Mar 2025 21:00:58 +0100 Subject: [PATCH] Port to new memory model: M_MEMORY_FULL cannot return anymore --- m-array.h | 21 ++++----------------- m-bitset.h | 8 +------- m-buffer.h | 3 --- m-c-mempool.h | 4 ---- m-dict.h | 8 +------- m-genint.h | 1 - m-i-shared.h | 1 - m-list.h | 8 -------- m-mempool.h | 2 -- m-rbtree.h | 3 --- m-shared-ptr.h | 4 ---- m-shared.h | 4 ---- m-snapshot.h | 2 -- m-string.h | 9 --------- m-tree.h | 5 ----- m-worker.h | 1 - 16 files changed, 6 insertions(+), 78 deletions(-) diff --git a/m-array.h b/m-array.h index 2163203d..e09a2469 100644 --- a/m-array.h +++ b/m-array.h @@ -246,7 +246,6 @@ type *ptr = M_CALL_REALLOC(oplist, type, d->ptr, d->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL)) { \ M_MEMORY_FULL(type, alloc); \ - return ; \ } \ d->ptr = ptr; \ d->alloc = alloc; \ @@ -323,14 +322,12 @@ M_ASSERT(v->size == v->alloc); \ size_t alloc = M_CALL_INC_ALLOC(oplist, v->alloc); \ if (M_UNLIKELY_NOMEM (alloc <= v->alloc)) { \ - M_MEMORY_FULL(type, -1U); \ - return NULL; \ + M_MEMORY_FULL(type, -(size_t)1); \ } \ M_ASSERT (alloc > v->size); \ type *ptr = M_CALL_REALLOC(oplist, type, v->ptr, v->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(type, alloc); \ - return NULL; \ } \ v->ptr = ptr; \ v->alloc = alloc; \ @@ -388,14 +385,12 @@ M_ASSERT(v->size == v->alloc); \ size_t alloc = M_CALL_INC_ALLOC(oplist, v->alloc); \ if (M_UNLIKELY_NOMEM (alloc <= v->alloc)) { \ - M_MEMORY_FULL(type, -1U); \ - return ; \ + M_MEMORY_FULL(type, -(size_t)1); \ } \ M_ASSERT (alloc > v->size); \ type *ptr = M_CALL_REALLOC(oplist, type, v->ptr, v->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(type, alloc); \ - return; \ } \ v->ptr = ptr; \ v->alloc = alloc; \ @@ -426,7 +421,6 @@ type *ptr = M_CALL_REALLOC(oplist, type, v->ptr, v->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(type, alloc); \ - return; \ } \ v->ptr = ptr; \ v->alloc = alloc; \ @@ -456,7 +450,6 @@ type *ptr = M_CALL_REALLOC(oplist, type, v->ptr, v->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(type, alloc); \ - return; \ } \ v->ptr = ptr; \ v->alloc = alloc; \ @@ -476,13 +469,11 @@ size_t alloc = M_CALL_INC_ALLOC(oplist, size) ; \ /* In case of overflow of size_t */ \ if (M_UNLIKELY_NOMEM (alloc <= v->alloc)) { \ - M_MEMORY_FULL(type, -1U); \ - return NULL; \ + M_MEMORY_FULL(type, -(size_t)1); \ } \ type *ptr = M_CALL_REALLOC(oplist, type, v->ptr, v->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(type, alloc); \ - return NULL; \ } \ v->ptr = ptr; \ v->alloc = alloc; \ @@ -602,19 +593,16 @@ /* Unlikely case of nothing to do */ \ if (num == 0) return; \ M_MEMORY_FULL(type, v->size); \ - return ; \ } \ /* Test if alloc array is sufficient */ \ if (size > v->alloc) { \ size_t alloc = M_CALL_INC_ALLOC(oplist, size) ; \ if (M_UNLIKELY_NOMEM (alloc <= v->alloc)) { \ - M_MEMORY_FULL(type, -1U); \ - return ; \ + M_MEMORY_FULL(type, -(size_t)1); \ } \ type *ptr = M_CALL_REALLOC(oplist, type, v->ptr, v->alloc, alloc); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(type, alloc); \ - return; \ } \ v->ptr = ptr; \ v->alloc = alloc; \ @@ -901,7 +889,6 @@ type *temp = M_CALL_REALLOC(oplist, type, NULL, 0, l->size); \ if (M_UNLIKELY_NOMEM (temp == NULL)) { \ M_MEMORY_FULL(type, l->size); \ - return ; \ } \ M_C3(m_arra4_,name,_stable_sort_noalloc)(l->ptr, l->size, temp); \ M_CALL_FREE(oplist, type, temp, l->size); \ diff --git a/m-bitset.h b/m-bitset.h index b1932396..f9a41e3d 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -125,7 +125,6 @@ M_P(void, m_bitset, _set, m_bitset_t d, const m_bitset_t s) m_b1tset_limb_ct *ptr = M_MEMORY_REALLOC (m_b1tset_limb_ct, d->ptr, d->alloc, needAlloc); if (M_UNLIKELY_NOMEM (ptr == NULL)) { M_MEMORY_FULL(m_b1tset_limb_ct, needAlloc); - return ; } d->ptr = ptr; d->alloc = needAlloc; @@ -208,14 +207,12 @@ M_P(void, m_bitset, _push_back, m_bitset_t v, bool x) // Check for integer overflow if (M_UNLIKELY_NOMEM (needAlloc <= v->alloc)) { M_MEMORY_FULL(m_b1tset_limb_ct, needAlloc); - return; } // Alloc memory m_b1tset_limb_ct *ptr = M_MEMORY_REALLOC (m_b1tset_limb_ct, v->ptr, v->alloc, needAlloc); // Check if success if (M_UNLIKELY_NOMEM (ptr == NULL) ) { M_MEMORY_FULL(m_b1tset_limb_ct, needAlloc); - return; } v->ptr = ptr; v->alloc = needAlloc; @@ -242,8 +239,7 @@ M_P(void, m_bitset, _resize, m_bitset_t v, size_t size) M_B1TSET_CONTRACT (v); // Check for overflow if (M_UNLIKELY_NOMEM (size >= ((size_t)-1) - M_B1TSET_LIMB_BIT)) { - M_MEMORY_FULL(char, (size_t) -1); - return; + M_MEMORY_FULL(char, -(size_t)1); } // Compute the needed allocation. size_t newAlloc = M_B1TSET_TO_ALLOC (size); @@ -252,7 +248,6 @@ M_P(void, m_bitset, _resize, m_bitset_t v, size_t size) m_b1tset_limb_ct *ptr = M_MEMORY_REALLOC (m_b1tset_limb_ct, v->ptr, v->alloc, newAlloc); if (M_UNLIKELY_NOMEM (ptr == NULL) ) { M_MEMORY_FULL(m_b1tset_limb_ct, newAlloc); - return; } v->ptr = ptr; v->alloc = newAlloc; @@ -303,7 +298,6 @@ M_P(void, m_bitset, _reserve, m_bitset_t v, size_t alloc) m_b1tset_limb_ct *ptr = M_MEMORY_REALLOC (m_b1tset_limb_ct, v->ptr, v->alloc, newAlloc); if (M_UNLIKELY_NOMEM (ptr == NULL) ) { M_MEMORY_FULL(m_b1tset_limb_ct, newAlloc); - return; } v->ptr = ptr; v->alloc = newAlloc; diff --git a/m-buffer.h b/m-buffer.h index 5fda050c..a537689c 100644 --- a/m-buffer.h +++ b/m-buffer.h @@ -322,7 +322,6 @@ M_P(void, name, _init, buffer_t v, size_t size) \ v->data = M_CALL_REALLOC(oplist, M_F(name, _el_ct), NULL, 0, M_BUFF3R_SIZE(m_size)); \ if (M_UNLIKELY_NOMEM (v->data == NULL)) { \ M_MEMORY_FULL (M_F(name, _el_ct), M_BUFF3R_SIZE(m_size)); \ - return; \ } \ ) \ if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \ @@ -893,7 +892,6 @@ M_P(void, name, _init, buffer_t v, size_t size) \ buffer->Tab = M_CALL_REALLOC(oplist, M_F(name, _el_ct), NULL, 0, size); \ if (M_UNLIKELY_NOMEM (buffer->Tab == NULL)) { \ M_MEMORY_FULL (M_F(name, _el_ct), size); \ - return; \ } \ for(unsigned int j = 0; j < (unsigned int) size; j++) { \ atomic_init(&buffer->Tab[j].seq, 2*j+1U); \ @@ -1233,7 +1231,6 @@ M_P(void, name, _init, buffer_t v, size_t size) \ buffer->Tab = M_CALL_REALLOC(oplist, M_F(name, _el_ct), NULL, 0, size); \ if (M_UNLIKELY_NOMEM (buffer->Tab == NULL)) { \ M_MEMORY_FULL (M_F(name, _el_ct), size); \ - return; \ } \ if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \ for(unsigned int j = 0; j < (unsigned int) size; j++) { \ diff --git a/m-c-mempool.h b/m-c-mempool.h index a1b0633f..cc7aa6fa 100644 --- a/m-c-mempool.h +++ b/m-c-mempool.h @@ -313,7 +313,6 @@ M_BEGIN_PROTECTED_CODE node = M_MEMORY_ALLOC(M_F(name, _lf_node_t)); \ if (M_UNLIKELY_NOMEM (node == NULL)) { \ M_MEMORY_FULL(M_F(name, _lf_node_t), 1); \ - return NULL; \ } \ atomic_init(&node->next, (M_F(name, _lf_node_t) *) 0); \ atomic_init(&node->cpt, 0UL); \ @@ -323,7 +322,6 @@ M_BEGIN_PROTECTED_CODE n = M_MEMORY_ALLOC(M_F(name, _slist_node_ct)); \ if (M_UNLIKELY_NOMEM (n == NULL)) { \ M_MEMORY_FULL(M_F(name, _lf_node_t), 1); \ - return NULL; \ } \ M_F(name, _slist_push)(node->list, n); \ } \ @@ -467,7 +465,6 @@ M_BEGIN_PROTECTED_CODE mem->thread_data = M_MEMORY_REALLOC(M_F(name, _lfmp_thread_ct), NULL, 0, max_thread); \ if (M_UNLIKELY_NOMEM (mem->thread_data == NULL)) { \ M_MEMORY_FULL(M_F(name, _lfmp_thread_ct), max_thread); \ - return; \ } \ for(unsigned i = 0; i < max_thread;i++) { \ M_F(name, _lfmp_thread_init)(&mem->thread_data[i]); \ @@ -590,7 +587,6 @@ m_gc_init(m_gc_t gc_mem, size_t max_thread) gc_mem->thread_data = M_MEMORY_REALLOC(m_gc_lfmp_thread_ct, NULL, 0, max_thread); if (M_UNLIKELY_NOMEM (gc_mem->thread_data == NULL)) { M_MEMORY_FULL(m_gc_lfmp_thread_ct, max_thread); - return; } for(unsigned i = 0; i < max_thread;i++) { atomic_init(&gc_mem->thread_data[i].ticket, ULONG_MAX); diff --git a/m-dict.h b/m-dict.h index ed576162..93db9be8 100644 --- a/m-dict.h +++ b/m-dict.h @@ -338,7 +338,6 @@ M_ARRAY_DEF(m_array_index, m_indexhash_t, M_POD_OPLIST) map->data = M_CALL_REALLOC(key_oplist, M_F(name, _freelist_ct), NULL, 0, (size_t) 1+2+map->upper_limit); \ if (M_UNLIKELY_NOMEM (map->data == NULL)) { \ M_MEMORY_FULL(M_F(name, _freelist_ct), 2+M_D1CT_INITIAL_SIZE); \ - return ; \ } \ map->freelist_first_data = 0; \ map->freelist_count = 2; \ @@ -346,7 +345,6 @@ M_ARRAY_DEF(m_array_index, m_indexhash_t, M_POD_OPLIST) map->index = M_CALL_REALLOC(key_oplist, m_indexhash_t, NULL, 0, (size_t)(0+M_D1CT_INITIAL_SIZE)); \ if (M_UNLIKELY_NOMEM (map->index == NULL)) { \ M_MEMORY_FULL(m_indexhash_t, 2+M_D1CT_INITIAL_SIZE); \ - return ; \ } \ /* Populate the initial table with the 'empty' representation which is 0 */ \ for(m_index_t i = 0; i < M_D1CT_INITIAL_SIZE; i++) { \ @@ -470,14 +468,12 @@ M_ARRAY_DEF(m_array_index, m_indexhash_t, M_POD_OPLIST) h->data = M_CALL_REALLOC(key_oplist, M_F(name, _freelist_ct), h->data, h->freelist_cap, (size_t) 1+2+h->upper_limit); \ if (M_UNLIKELY_NOMEM (h->data == NULL) ) { \ M_MEMORY_FULL(M_F(name, _freelist_ct), 2+newSize); \ - return ; \ } \ h->freelist_cap = 1+2+h->upper_limit; \ } \ m_indexhash_t *index = M_CALL_REALLOC(key_oplist, m_indexhash_t, h->index, oldSize, (size_t)0+newSize); \ if (M_UNLIKELY_NOMEM (index == NULL) ) { \ M_MEMORY_FULL(m_indexhash_t, newSize); \ - return ; \ } \ h->index = index; \ \ @@ -1468,7 +1464,6 @@ enum m_d1ct_oa_element_e { dict->data = M_CALL_REALLOC(key_oplist, M_F(name, _pair_ct), NULL, 0, M_D1CT_INITIAL_SIZE); \ if (M_UNLIKELY_NOMEM (dict->data == NULL)) { \ M_MEMORY_FULL(M_F(name, _pair_ct), M_D1CT_INITIAL_SIZE); \ - return ; \ } \ /* Populate the initial table with the 'empty' representation */ \ for(size_t i = 0; i < M_D1CT_INITIAL_SIZE; i++) { \ @@ -1547,7 +1542,6 @@ enum m_d1ct_oa_element_e { data = M_CALL_REALLOC(key_oplist, M_F(name, _pair_ct), data, oldSize, newSize); \ if (M_UNLIKELY_NOMEM (data == NULL) ) { \ M_MEMORY_FULL(M_F(name, _pair_ct), newSize); \ - return ; \ } \ \ /* First mark the extended space as empty */ \ @@ -1670,7 +1664,7 @@ enum m_d1ct_oa_element_e { if (dict->count > (dict->mask / 2)) { \ newSize += newSize; \ if (M_UNLIKELY_NOMEM (newSize <= dict->mask+1)) { \ - M_MEMORY_FULL(char, (size_t)-1); \ + M_MEMORY_FULL(char, -(size_t)1); \ } \ } \ M_F(name,_i_resize_up)M_R(dict, newSize, true); \ diff --git a/m-genint.h b/m-genint.h index 3e3e7e52..49b6a8ae 100644 --- a/m-genint.h +++ b/m-genint.h @@ -111,7 +111,6 @@ M_P(void, m_genint, _init, m_genint_t s, unsigned int n) atomic_ullong *ptr = M_MEMORY_REALLOC (atomic_ullong, NULL, 0, alloc); if (M_UNLIKELY_NOMEM (ptr == NULL)) { M_MEMORY_FULL(atomic_ullong, alloc); - return; } s->n = n; s->data = ptr; diff --git a/m-i-shared.h b/m-i-shared.h index d1bcc1cd..1dfe6ae4 100644 --- a/m-i-shared.h +++ b/m-i-shared.h @@ -193,7 +193,6 @@ M_BEGIN_PROTECTED_CODE type *ptr = M_CALL_NEW(oplist, type); \ if (M_UNLIKELY_NOMEM (ptr == NULL)) { \ M_MEMORY_FULL(type, 1); \ - return NULL; \ } \ M_CALL_INIT(oplist, *ptr); \ atomic_init (&ptr->M_F(name, _cpt), 2); \ diff --git a/m-list.h b/m-list.h index 3b48c6e7..d082905d 100644 --- a/m-list.h +++ b/m-list.h @@ -253,7 +253,6 @@ struct M_F(name, _s) *next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return NULL; \ } \ type *ret = &next->data; \ next->next = *v; \ @@ -467,7 +466,6 @@ struct M_F(name, _s) *next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return; \ } \ M_ON_EXCEPTION( M_CALL_DEL(oplist, next)) \ M_CALL_INIT_SET(oplist, next->data, x); \ @@ -519,8 +517,6 @@ next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - *update_list = NULL; \ - return; \ } \ M_CALL_INIT_SET(oplist, next->data, it_org->data); \ *update_list = next; \ @@ -1012,7 +1008,6 @@ struct M_F(name, _s) *next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return NULL; \ } \ type *ret = &next->data; \ next->next = v->back; \ @@ -1122,7 +1117,6 @@ struct M_F(name, _s) *next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return NULL; \ } \ type *ret = &next->data; \ next->next = NULL; \ @@ -1281,7 +1275,6 @@ struct M_F(name, _s) *m_volatile next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return; \ } \ M_ON_EXCEPTION( M_CALL_DEL(oplist, next)) \ M_CALL_INIT_SET(oplist, next->data, x); \ @@ -1341,7 +1334,6 @@ next = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (next == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return; \ } \ M_CALL_INIT_SET(oplist, next->data, it_org->data); \ /* Link new node to the previous one*/ \ diff --git a/m-mempool.h b/m-mempool.h index 1d600afc..c8d9b301 100644 --- a/m-mempool.h +++ b/m-mempool.h @@ -119,7 +119,6 @@ mem->current_segment = M_MEMORY_ALLOC(M_F(name,_segment_ct)); \ if (M_UNLIKELY_NOMEM(mem->current_segment == NULL)) { \ M_MEMORY_FULL(M_F(name,_segment_ct), 1); \ - return; \ } \ mem->current_segment->next = NULL; \ mem->current_segment->count = 0; \ @@ -161,7 +160,6 @@ M_F(name,_segment_ct) *new_segment = M_MEMORY_ALLOC (M_F(name,_segment_ct)); \ if (M_UNLIKELY_NOMEM (new_segment == NULL)) { \ M_MEMORY_FULL(M_F(name,_segment_ct), 1); \ - return NULL; \ } \ new_segment->next = segment; \ new_segment->count = 0; \ diff --git a/m-rbtree.h b/m-rbtree.h index f9e8086d..aca9f769 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -288,7 +288,6 @@ typedef enum { n = M_CALL_NEW(oplist, node_t); \ if (M_UNLIKELY_NOMEM (n == NULL)) { \ M_MEMORY_FULL(node_t, 1); \ - return; \ } \ /* Copy the data in the root node */ \ M_CALL_INIT_SET(oplist, n->data, data); \ @@ -329,7 +328,6 @@ typedef enum { n = M_CALL_NEW(oplist, node_t); \ if (M_UNLIKELY_NOMEM (n == NULL) ) { \ M_MEMORY_FULL (node_t, 1); \ - return; \ } \ /* Copy the data and mark the node as red */ \ M_CALL_INIT_SET(oplist, n->data, data); \ @@ -659,7 +657,6 @@ typedef enum { node_t *n = M_CALL_NEW(oplist, node_t); \ if (M_UNLIKELY_NOMEM (n == NULL) ) { \ M_MEMORY_FULL (node_t, 1); \ - return NULL; \ } \ M_CALL_INIT_SET(oplist, n->data, o->data); \ n->child[0] = M_F(name,_i_copy_node)M_R(o->child[0]); \ diff --git a/m-shared-ptr.h b/m-shared-ptr.h index 059811a9..a68f0f64 100644 --- a/m-shared-ptr.h +++ b/m-shared-ptr.h @@ -616,7 +616,6 @@ M_IF_METHOD(INIT, oplist)( \ shared_t *out = M_CALL_NEW(oplist, shared_t); \ if (M_UNLIKELY_NOMEM( out == NULL)) { \ M_MEMORY_FULL(shared_t, 1); \ - abort(); \ } \ M_ON_EXCEPTION( M_CALL_DEL(oplist, out) ) \ M_CALL_INIT(oplist, out->data); \ @@ -632,7 +631,6 @@ M_IF_METHOD(INIT_SET, oplist)( \ shared_t *out = M_CALL_NEW(oplist, shared_t); \ if (M_UNLIKELY_NOMEM( out == NULL)) { \ M_MEMORY_FULL(shared_t, 1); \ - abort(); \ } \ M_F(name, _read_lock)(src); \ M_ON_EXCEPTION( M_F(name, _read_unlock)(src), M_CALL_DEL(oplist, out) ) \ @@ -649,7 +647,6 @@ M_IF_METHOD(INIT_SET, oplist)( \ shared_t *out = M_CALL_NEW(oplist, shared_t); \ if (M_UNLIKELY_NOMEM( out == NULL)) { \ M_MEMORY_FULL(shared_t, 1); \ - abort(); \ } \ M_ON_EXCEPTION( M_CALL_DEL(oplist, out) ) \ M_CALL_INIT_SET(oplist, out->data, src); \ @@ -707,7 +704,6 @@ M_PAIR_2 name_attr shared_t *function_name(M_EMPLACE_LIST_TYPE_VAR_ALTER(a, exp_ shared_t *out = M_CALL_NEW(oplist, shared_t); \ if (M_UNLIKELY_NOMEM( out == NULL)) { \ M_MEMORY_FULL(shared_t, 1); \ - abort(); \ } \ M_ON_EXCEPTION( M_CALL_DEL(oplist, out) ) \ M_EMPLACE_CALL_FUNC(a, init_func, oplist, out->data, exp_emplace_type); \ diff --git a/m-shared.h b/m-shared.h index 59622be6..3509533a 100644 --- a/m-shared.h +++ b/m-shared.h @@ -212,7 +212,6 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; } ptr = M_CALL_NEW(oplist, struct M_F(name, _s)); \ if (M_UNLIKELY_NOMEM (ptr == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _s), 1); \ - return; \ } \ ptr->data = data; \ M_CALL_INIT_SET(cpt_oplist, &ptr->cpt, 1); \ @@ -230,7 +229,6 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; } M_CALL_NEW(oplist, struct M_F(name, _combine_s)); \ if (M_UNLIKELY_NOMEM (p == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _combine_s), 1); \ - return; \ } \ struct M_F(name, _s) *ptr = &p->ptr; \ ptr->combineAlloc = true; \ @@ -377,7 +375,6 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; } M_CALL_NEW(oplist, struct M_F(name, _combine_s)); \ if (M_UNLIKELY_NOMEM (p == NULL)) { \ M_MEMORY_FULL(struct M_F(name, _combine_s), 1); \ - return; \ } \ struct M_F(name, _s) *ptr = &p->ptr; \ ptr->combineAlloc = true; \ @@ -448,7 +445,6 @@ M_INLINE int m_shar3d_integer_cref(int *p) { return *p; } s->buffer = M_CALL_REALLOC(oplist, M_F(name, _atype_ct), NULL, 0, n); \ if (M_UNLIKELY_NOMEM (s->buffer == NULL)) { \ M_MEMORY_FULL(M_F(name, _atype_ct), n); \ - return; \ } \ for(size_t i = 0; i < n; i++) { \ M_CALL_INIT(oplist, s->buffer[i].x); \ diff --git a/m-snapshot.h b/m-snapshot.h index 3ebfc379..614e346d 100644 --- a/m-snapshot.h +++ b/m-snapshot.h @@ -394,7 +394,6 @@ m_snapsh0t_mrsw_init(m_snapsh0t_mrsw_ct s, size_t n) atomic_uint *ptr = M_MEMORY_REALLOC (atomic_uint, NULL, 0, n); if (M_UNLIKELY_NOMEM (ptr == NULL)) { M_MEMORY_FULL(atomic_uint, n); - return; } s->cptTab = ptr; for(size_t i = 0; i < n; i++) @@ -649,7 +648,6 @@ m_snapsh0t_mrsw_read_end(m_snapsh0t_mrsw_ct s, unsigned int idx) if (M_UNLIKELY_NOMEM (snap->data == NULL)) { \ M_MEMORY_FULL(M_F(name, _aligned_type_ct), \ (nReader+M_SNAPSH0T_SPMC_EXTRA_BUFFER)); \ - return; \ } \ for(size_t i = 0; i < nReader + M_SNAPSH0T_SPMC_EXTRA_BUFFER; i++) { \ M_CALL_INIT(oplist, snap->data[i].x); \ diff --git a/m-string.h b/m-string.h index 4d52ff11..b4d12237 100644 --- a/m-string.h +++ b/m-string.h @@ -312,7 +312,6 @@ M_P(char *, m_string, _clear_get_cstr, m_string_t v) char *ptr = M_MEMORY_REALLOC (char, NULL, 0, alloc); if (M_UNLIKELY_NOMEM (ptr == NULL)) { M_MEMORY_FULL(char, alloc); - return NULL; } M_ASSERT(ptr != NULL && p != NULL); memcpy(ptr, p, alloc); @@ -384,18 +383,12 @@ M_P(char *, m_str1ng, _fit2size, m_string_t v, size_t size_alloc) if (M_UNLIKELY_NOMEM (alloc <= size_alloc)) { /* Overflow in alloc computation */ M_MEMORY_FULL(char, alloc); - // NOTE: Return is currently broken. - abort(); - return NULL; } char *ptr = m_str1ng_embedded_p(v) ? NULL : v->u.heap.ptr; //FIXME: old_alloc may not be NULL if ptr is NULL. ptr = M_MEMORY_REALLOC (char, ptr, old_alloc, alloc); if (M_UNLIKELY_NOMEM (ptr == NULL)) { M_MEMORY_FULL(char, alloc); - // NOTE: Return is currently broken. - abort(); - return NULL; } // The pointer cannot be the embedded buffer of the string as it is heap allocated M_ASSERT(ptr != &v->u.buffer[0]); @@ -449,13 +442,11 @@ M_P(void, m_string, _reserve, m_string_t v, size_t alloc) size_t r_alloc = m_str1ng_round_capacity(&m, &e, (m_str1ng_size_t) alloc); if (M_UNLIKELY_NOMEM (alloc > r_alloc)) { M_MEMORY_FULL(char, alloc); - return; } char *ptr = m_str1ng_embedded_p(v) ? NULL : v->u.heap.ptr; ptr = M_MEMORY_REALLOC (char, ptr, m_string_capacity(v), r_alloc); if (M_UNLIKELY_NOMEM (ptr == NULL) ) { M_MEMORY_FULL(char, alloc); - return; } if (m_str1ng_embedded_p(v)) { // Copy the characters embedded in the structure to the allocated heap space diff --git a/m-tree.h b/m-tree.h index c767f118..4610022f 100644 --- a/m-tree.h +++ b/m-tree.h @@ -261,7 +261,6 @@ typedef int32_t m_tr33_index_t; /* Realloc the array */ \ if (M_UNLIKELY_NOMEM (alloc >= INT32_MAX)) { \ M_MEMORY_FULL(struct M_F(name, _node_s), alloc); \ - return; \ } \ /* Allocate one more term in the array so that tab[-1] exists. \ This enables performing latter tab[M_TR33_NO_NODE].x = something; \ @@ -271,7 +270,6 @@ typedef int32_t m_tr33_index_t; ptr = M_CALL_REALLOC(oplist, struct M_F(name, _node_s), ptr, (size_t)(tree->capacity+1), alloc+1); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(struct M_F(name, _node_s), alloc); \ - return; \ } \ /* Skip the first term to keep it as empty & unused */ \ ptr++; \ @@ -315,7 +313,6 @@ typedef int32_t m_tr33_index_t; alloc += tree->allow_realloc; \ if (M_UNLIKELY_NOMEM (alloc >= INT32_MAX)) { \ M_MEMORY_FULL(struct M_F(name, _node_s), alloc); \ - return M_TR33_NO_NODE; \ } \ /* Allocate one more term in the array so that tab[-1] exists. \ This enables performing latter tab[M_TR33_NO_NODE].x = something; \ @@ -325,7 +322,6 @@ typedef int32_t m_tr33_index_t; ptr = M_CALL_REALLOC(oplist, struct M_F(name, _node_s), ptr, (size_t)(tree->capacity+1), alloc+1); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(struct M_F(name, _node_s), alloc); \ - return M_TR33_NO_NODE; \ } \ /* Skip the first term to keep it as empty & unused */ \ ptr++; \ @@ -1137,7 +1133,6 @@ typedef int32_t m_tr33_index_t; M_CALL_REALLOC(oplist, struct M_F(name, _node_s), NULL, 0, alloc+1); \ if (M_UNLIKELY_NOMEM (ptr == NULL) ) { \ M_MEMORY_FULL(struct M_F(name, _node_s), alloc); \ - return; \ } \ tree->tab = ++ptr; \ /* We don't scan recursively the node tree, but sequentially */ \ diff --git a/m-worker.h b/m-worker.h index dae7068e..e8d58d70 100644 --- a/m-worker.h +++ b/m-worker.h @@ -412,7 +412,6 @@ m_worker_init(m_worker_t g, int numWorker, unsigned int extraQueue, void (*reset g->worker = M_MEMORY_REALLOC(m_work3r_thread_ct, NULL, 0, numWorker_st); if (M_UNLIKELY_NOMEM (g->worker == NULL)) { M_MEMORY_FULL(m_work3r_thread_ct, numWorker_st); - return; } m_work3r_queue_init(g->queue_g, numWorker_st + extraQueue); g->numWorker_g = (unsigned int) numWorker_st;