From 95fb19d661154ba8cfc6c793a0daa25657294b3b Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 8 Apr 2013 08:17:23 +0200 Subject: fontconfig libXau mesa xserver xkeyboard-config git update 8 Apr 2013 xserver commit 8928f8fa0bb154ce437af703ff702016f0dcf127 xkeyboard-config commit e5c6729f3679fe87a703eb1d7ec1cf0a61814ca8 libXau commit f5a57d8a21a34d7084cce294e24c0422e02ef8ef fontconfig commit 18bf57c70aafcad031c0b43756b754dcaf6a756a mesa commit eff66bc9f855fff5c4f5f57f247254a97431e8ad --- .../src/gallium/auxiliary/util/u_debug_memory.c | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'mesalib/src/gallium/auxiliary/util/u_debug_memory.c') diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_memory.c b/mesalib/src/gallium/auxiliary/util/u_debug_memory.c index 4bf26a524..472354781 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug_memory.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug_memory.c @@ -76,6 +76,7 @@ struct debug_memory_header #endif unsigned magic; + unsigned tag; }; struct debug_memory_footer @@ -140,6 +141,7 @@ debug_malloc(const char *file, unsigned line, const char *function, hdr->function = function; hdr->size = size; hdr->magic = DEBUG_MEMORY_MAGIC; + hdr->tag = 0; #if DEBUG_FREED_MEMORY hdr->freed = FALSE; #endif @@ -263,6 +265,7 @@ debug_realloc(const char *file, unsigned line, const char *function, new_hdr->function = old_hdr->function; new_hdr->size = new_size; new_hdr->magic = DEBUG_MEMORY_MAGIC; + new_hdr->tag = 0; #if DEBUG_FREED_MEMORY new_hdr->freed = FALSE; #endif @@ -347,6 +350,58 @@ debug_memory_end(unsigned long start_no) } +/** + * Put a tag (arbitrary integer) on a memory block. + * Can be useful for debugging. + */ +void +debug_memory_tag(void *ptr, unsigned tag) +{ + struct debug_memory_header *hdr; + + if (!ptr) + return; + + hdr = header_from_data(ptr); + if (hdr->magic != DEBUG_MEMORY_MAGIC) { + debug_printf("%s corrupted memory at %p\n", __FUNCTION__, ptr); + debug_assert(0); + } + + hdr->tag = tag; +} + + +/** + * Check the given block of memory for validity/corruption. + */ +void +debug_memory_check_block(void *ptr) +{ + struct debug_memory_header *hdr; + struct debug_memory_footer *ftr; + + if (!ptr) + return; + + hdr = header_from_data(ptr); + ftr = footer_from_header(hdr); + + if (hdr->magic != DEBUG_MEMORY_MAGIC) { + debug_printf("%s:%u:%s: bad or corrupted memory %p\n", + hdr->file, hdr->line, hdr->function, ptr); + debug_assert(0); + } + + if (ftr->magic != DEBUG_MEMORY_MAGIC) { + debug_printf("%s:%u:%s: buffer overflow %p\n", + hdr->file, hdr->line, hdr->function, ptr); + debug_assert(0); + } +} + + + /** * We can periodically call this from elsewhere to do a basic sanity * check of the heap memory we've allocated. -- cgit v1.2.3