summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2018-11-11 13:36:29 -0800
committerMatt Turner <[email protected]>2018-11-12 20:54:49 -0800
commit7e3748c268cd817b1b91f403baa7677db82ce1c1 (patch)
tree398e5630c968f896e9c4dcfe17db78e2b3cd45f4
parent34dffcf9132fa2a831f417968e1c8e0fadc6dd77 (diff)
util/ralloc: Switch from DEBUG to NDEBUG
The debug code is all asserts, so protect it with the same thing that controls assert. Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/util/ralloc.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/util/ralloc.c b/src/util/ralloc.c
index 5d77f75ee85..745b4cf1226 100644
--- a/src/util/ralloc.c
+++ b/src/util/ralloc.c
@@ -61,7 +61,7 @@ struct
#endif
ralloc_header
{
-#ifdef DEBUG
+#ifndef NDEBUG
/* A canary value used to determine whether a pointer is ralloc'd. */
unsigned canary;
#endif
@@ -88,9 +88,7 @@ get_header(const void *ptr)
{
ralloc_header *info = (ralloc_header *) (((char *) ptr) -
sizeof(ralloc_header));
-#ifdef DEBUG
assert(info->canary == CANARY);
-#endif
return info;
}
@@ -140,7 +138,7 @@ ralloc_size(const void *ctx, size_t size)
add_child(parent, info);
-#ifdef DEBUG
+#ifndef NDEBUG
info->canary = CANARY;
#endif
@@ -558,7 +556,7 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
#define LMAGIC 0x87b9c7d3
struct linear_header {
-#ifdef DEBUG
+#ifndef NDEBUG
unsigned magic; /* for debugging */
#endif
unsigned offset; /* points to the first unused byte in the buffer */
@@ -608,7 +606,7 @@ create_linear_node(void *ralloc_ctx, unsigned min_size)
if (unlikely(!node))
return NULL;
-#ifdef DEBUG
+#ifndef NDEBUG
node->magic = LMAGIC;
#endif
node->offset = 0;
@@ -628,9 +626,7 @@ linear_alloc_child(void *parent, unsigned size)
linear_size_chunk *ptr;
unsigned full_size;
-#ifdef DEBUG
assert(first->magic == LMAGIC);
-#endif
assert(!latest->next);
size = ALIGN_POT(size, SUBALLOC_ALIGNMENT);
@@ -702,9 +698,7 @@ linear_free_parent(void *ptr)
return;
node = LINEAR_PARENT_TO_HEADER(ptr);
-#ifdef DEBUG
assert(node->magic == LMAGIC);
-#endif
while (node) {
void *ptr = node;
@@ -723,9 +717,7 @@ ralloc_steal_linear_parent(void *new_ralloc_ctx, void *ptr)
return;
node = LINEAR_PARENT_TO_HEADER(ptr);
-#ifdef DEBUG
assert(node->magic == LMAGIC);
-#endif
while (node) {
ralloc_steal(new_ralloc_ctx, node);
@@ -738,9 +730,7 @@ void *
ralloc_parent_of_linear_parent(void *ptr)
{
linear_header *node = LINEAR_PARENT_TO_HEADER(ptr);
-#ifdef DEBUG
assert(node->magic == LMAGIC);
-#endif
return node->ralloc_parent;
}