From fc34fa80b5d90bf07ed2a248a3cbd015d2483451 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Fri, 7 Apr 2023 23:50:03 +0200 Subject: [PATCH] Properly mark condition for entering memory failure. --- m-mempool.h | 4 ++-- m-rbtree.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/m-mempool.h b/m-mempool.h index 612e5257..36b89c6a 100644 --- a/m-mempool.h +++ b/m-mempool.h @@ -114,7 +114,7 @@ { \ mem->free_list = NULL; \ mem->current_segment = M_MEMORY_ALLOC(M_C(name,_segment_ct)); \ - if (mem->current_segment == NULL) { \ + if (M_UNLIKELY_NOMEM(mem->current_segment == NULL)) { \ M_MEMORY_FULL(sizeof (M_C(name,_segment_ct))); \ return; \ } \ @@ -156,7 +156,7 @@ /* If segment is full, allocate a new one from the system */ \ if (M_UNLIKELY (count >= M_USE_MEMPOOL_MAX_PER_SEGMENT(type))) { \ M_C(name,_segment_ct) *new_segment = M_MEMORY_ALLOC (M_C(name,_segment_ct)); \ - if (M_UNLIKELY (new_segment == NULL)) { \ + if (M_UNLIKELY_NOMEM (new_segment == NULL)) { \ M_MEMORY_FULL(sizeof (M_C(name,_segment_ct))); \ return NULL; \ } \ diff --git a/m-rbtree.h b/m-rbtree.h index 07730a90..663bfce9 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -320,7 +320,7 @@ typedef enum { /* If there is no root node, create a new node */ \ if (n == NULL) { \ n = M_C3(m_rbtr33_,name,_new)(); \ - if (M_UNLIKELY (n == NULL)) { \ + if (M_UNLIKELY_NOMEM (n == NULL)) { \ M_MEMORY_FULL(sizeof (node_t)); \ return; \ } \ @@ -361,7 +361,7 @@ typedef enum { } \ /* Create new node to store the data */ \ n = M_C3(m_rbtr33_,name,_new)(); \ - if (M_UNLIKELY (n == NULL) ) { \ + if (M_UNLIKELY_NOMEM (n == NULL) ) { \ M_MEMORY_FULL (sizeof (node_t)); \ return; \ } \ @@ -692,7 +692,7 @@ typedef enum { { \ if (o == NULL) return NULL; \ node_t *n = M_C3(m_rbtr33_,name,_new)(); \ - if (M_UNLIKELY (n == NULL) ) { \ + if (M_UNLIKELY_NOMEM (n == NULL) ) { \ M_MEMORY_FULL (sizeof (node_t)); \ return NULL; \ } \ @@ -795,7 +795,7 @@ typedef enum { \ M_IF_DEBUG( \ /* Compute the depth of a node */ \ - static size_t \ + static inline size_t \ M_C3(m_rbtr33_,name,_compute_depth)(const node_t *n) \ { \ if (n == NULL) return 1; \