Skip to content

Commit a9fa574

Browse files
authored
Merge pull request #1336 from ldorau/Disable_expensive_debug_checks
Disable expensive debug checks
2 parents 8c1a97b + 110016f commit a9fa574

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/base_alloc/base_alloc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct umf_ba_next_pool_t {
6767
};
6868

6969
#ifndef NDEBUG
70+
#ifdef UMF_DEVELOPER_MODE
7071
static void ba_debug_checks(umf_ba_pool_t *pool) {
7172
// count pools
7273
size_t n_pools = 1;
@@ -89,6 +90,12 @@ static void ba_debug_checks(umf_ba_pool_t *pool) {
8990
}
9091
assert(n_free_chunks == pool->metadata.n_chunks - pool->metadata.n_allocs);
9192
}
93+
#else /* !UMF_DEVELOPER_MODE */
94+
static inline void ba_debug_checks(umf_ba_pool_t *pool) {
95+
// no debug checks in release mode
96+
(void)pool; // suppress unused parameter warning
97+
}
98+
#endif /* !UMF_DEVELOPER_MODE */
9299
#endif /* NDEBUG */
93100

94101
// ba_divide_memory_into_chunks - divide given memory into chunks of chunk_size and add them to the free_list

src/coarse/coarse.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static inline ravl_node_t *get_node_next(ravl_node_t *node) {
130130
return ravl_node_successor(node);
131131
}
132132

133-
#ifndef NDEBUG
133+
#if !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE)
134134
static block_t *get_block_prev(ravl_node_t *node) {
135135
ravl_node_t *ravl_prev = ravl_node_predecessor(node);
136136
if (!ravl_prev) {
@@ -148,7 +148,7 @@ static block_t *get_block_next(ravl_node_t *node) {
148148

149149
return get_node_block(ravl_next);
150150
}
151-
#endif /* NDEBUG */
151+
#endif /* !defined(NDEBUG) && defined(UMF_DEVELOPER_MODE) */
152152

153153
// The functions "coarse_ravl_*" handles the coarse->all_blocks list of blocks
154154
// sorted by a pointer (block_t->data) to the beginning of the block data.
@@ -528,6 +528,7 @@ static ravl_node_t *free_block_merge_with_next(coarse_t *coarse,
528528
}
529529

530530
#ifndef NDEBUG // begin of DEBUG code
531+
#ifdef UMF_DEVELOPER_MODE
531532

532533
typedef struct debug_cb_args_t {
533534
coarse_t *provider;
@@ -606,6 +607,12 @@ static bool debug_check(coarse_t *provider) {
606607

607608
return true;
608609
}
610+
#else /* !UMF_DEVELOPER_MODE */
611+
static inline bool debug_check(coarse_t *provider) {
612+
(void)provider; // suppress unused variable warning
613+
return true;
614+
}
615+
#endif /* !UMF_DEVELOPER_MODE */
609616
#endif /* NDEBUG */ // end of DEBUG code
610617

611618
static umf_result_t coarse_add_used_block(coarse_t *coarse, void *addr,

0 commit comments

Comments
 (0)