Undefined data will eventually trigger a valgrind error while computing
its CRC32 while writing it into the disk cache, but at that point, it is
basically impossible to track down where the undefined data came from.
With this change, finding the origin of undefined data becomes easy.
v2: remove duplicate VALGRIND_CFLAGS (Emil)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
-I$(top_srcdir)/src/gtest/include \
+ $(VALGRIND_CFLAGS) \
$(DEFINES)
AM_CFLAGS = \
#include "main/macros.h"
#include "blob.h"
+#ifdef HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#define VG(x) x
+#else
+#define VG(x)
+#endif
+
#define BLOB_INITIAL_SIZE 4096
/* Ensure that \blob will be able to fit an additional object of size
if (blob->size < offset + to_write)
return false;
+ VG(VALGRIND_CHECK_MEM_IS_DEFINED(bytes, to_write));
+
memcpy(blob->data + offset, bytes, to_write);
return true;
if (! grow_to_fit(blob, to_write))
return false;
+ VG(VALGRIND_CHECK_MEM_IS_DEFINED(bytes, to_write));
+
memcpy(blob->data + blob->size, bytes, to_write);
blob->size += to_write;