X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fmem%2Fmem.h;h=19f69c038c67efe1e11ac8ab5cec036123aa3b95;hb=e16fc94bd8f80800d5203d9182cb3c5224528b0a;hp=a3403c4ee31dc8794f89acfd95836e5c17c4672a;hpb=2f00b7cc95a9dc9ac7c0cb42eee38bbb639576d6;p=ccan diff --git a/ccan/mem/mem.h b/ccan/mem/mem.h index a3403c4e..19f69c03 100644 --- a/ccan/mem/mem.h +++ b/ccan/mem/mem.h @@ -250,6 +250,7 @@ static inline void *memcheck_(const void *data, size_t len) #else static inline void *memcheck_(const void *data, size_t len) { + (void)len; return (void *)data; } #endif @@ -275,4 +276,20 @@ static inline void *memcheck_(const void *data, size_t len) #else #define memcheck(data, len) memcheck_((data), (len)) #endif + +/** + * memtaint - mark a memory region unused + * @data: start of region + * @len: length in bytes + * + * This writes an "0xdeadbeef" eyecatcher repeatedly to the memory. + * When running under valgrind, it also tells valgrind that the memory is + * uninitialized, triggering valgrind errors if it is used for branches + * or written out (or passed to memcheck!) in future. + * + * Example: + * // We'll reuse this buffer later, but be sure we don't access it. + * memtaint(somebytes, bytes_len); + */ +void memtaint(void *data, size_t len); #endif /* CCAN_MEM_H */