X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fralloc.c;h=36bc61fd07585c6db585a5d60797af3fb12a3beb;hb=97d8b770549584a2cd6b14956f15beeef0d83cad;hp=02816425221f9adc3105d73c07726a7bfac74a17;hpb=47bd6e46fe89e1cce61b11bcaa7b81f807011c23;p=mesa.git diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c index 02816425221..36bc61fd075 100644 --- a/src/glsl/ralloc.c +++ b/src/glsl/ralloc.c @@ -53,8 +53,10 @@ _CRTIMP int _vscprintf(const char *format, va_list argptr); struct ralloc_header { +#ifdef DEBUG /* A canary value used to determine whether a pointer is ralloc'd. */ unsigned canary; +#endif struct ralloc_header *parent; @@ -78,7 +80,9 @@ get_header(const void *ptr) { ralloc_header *info = (ralloc_header *) (((char *) ptr) - sizeof(ralloc_header)); +#ifdef DEBUG assert(info->canary == CANARY); +#endif return info; } @@ -107,15 +111,19 @@ void * ralloc_size(const void *ctx, size_t size) { void *block = calloc(1, size + sizeof(ralloc_header)); + ralloc_header *info; + ralloc_header *parent; if (unlikely(block == NULL)) return NULL; - ralloc_header *info = (ralloc_header *) block; - ralloc_header *parent = ctx != NULL ? get_header(ctx) : NULL; + info = (ralloc_header *) block; + parent = ctx != NULL ? get_header(ctx) : NULL; add_child(parent, info); +#ifdef DEBUG info->canary = CANARY; +#endif return PTR_FROM_HEADER(info); }