]> git.ozlabs.org Git - ccan/blobdiff - ccan/mem/mem.h
mem: add memtaint().
[ccan] / ccan / mem / mem.h
index a3403c4ee31dc8794f89acfd95836e5c17c4672a..f2c3d5c7a6f795e2e091df8a545992c6533b50ec 100644 (file)
@@ -275,4 +275,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 */