summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/malloc.h
diff options
context:
space:
mode:
authorPiotr Jaroszyński2010-07-01 03:47:52 +0200
committerMichael Brown2011-03-27 22:03:05 +0200
commitb604e8a388702df3cd4d3d64cf42dfc361b235c0 (patch)
treed3e581fc9462b3658fb1a2d354794108e85a3086 /src/include/ipxe/malloc.h
parent[image] Remove redundant call to basename() (diff)
downloadipxe-b604e8a388702df3cd4d3d64cf42dfc361b235c0.tar.gz
ipxe-b604e8a388702df3cd4d3d64cf42dfc361b235c0.tar.xz
ipxe-b604e8a388702df3cd4d3d64cf42dfc361b235c0.zip
[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 e8136a3c..c435a7dd 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 */