Module: Mesa Branch: staging/18.2-ci Commit: 4a8ce6291d9537f3af8831a8a23c994c1b689506 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a8ce6291d9537f3af8831a8a23c994c1b689506
Author: Matt Turner <[email protected]> Date: Sun Nov 11 13:36:29 2018 -0800 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]> (cherry picked from commit 7e3748c268cd817b1b91f403baa7677db82ce1c1) --- src/util/ralloc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/util/ralloc.c b/src/util/ralloc.c index 5d77f75ee8..745b4cf122 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; } _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
