aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/malloc.h
diff options
context:
space:
mode:
authorPiotr Jaroszyński <p.jaroszynski@gmail.com>2010-07-01 03:47:52 +0200
committerMichael Brown <mcb30@ipxe.org>2011-03-27 21:03:05 +0100
commitb604e8a388702df3cd4d3d64cf42dfc361b235c0 (patch)
treed3e581fc9462b3658fb1a2d354794108e85a3086 /src/include/ipxe/malloc.h
parent3c1bdfd5d905eb5e916d588d59494d53ea968eb0 (diff)
downloadipxe-b604e8a388702df3cd4d3d64cf42dfc361b235c0.tar.gz
[linux] Make malloc and linux_umalloc valgrindable
Make the allocators used by malloc and linux_umalloc valgrindable. Include valgrind headers in the codebase to avoid a build dependency on valgrind. Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/malloc.h')
-rw-r--r--src/include/ipxe/malloc.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/include/ipxe/malloc.h b/src/include/ipxe/malloc.h
index e8136a3ce..c435a7ddb 100644
--- a/src/include/ipxe/malloc.h
+++ b/src/include/ipxe/malloc.h
@@ -19,6 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/
#include <stdlib.h>
#include <ipxe/tables.h>
+#include <valgrind/memcheck.h>
extern size_t freemem;
@@ -39,7 +40,10 @@ extern void mdumpfree ( void );
* @c align must be a power of two. @c size may not be zero.
*/
static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
- return alloc_memblock ( size, phys_align );
+ void * ptr = alloc_memblock ( size, phys_align );
+ if ( ptr && size )
+ VALGRIND_MALLOCLIKE_BLOCK ( ptr, size, 0, 0 );
+ return ptr;
}
/**
@@ -55,6 +59,7 @@ static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
*/
static inline void free_dma ( void *ptr, size_t size ) {
free_memblock ( ptr, size );
+ VALGRIND_FREELIKE_BLOCK ( ptr, 0 );
}
/** A cache discarder */