#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
blob_create(void);
/**
+ * Destroy a blob and free its memory.
+ */
+static inline void
+blob_destroy(struct blob *blob)
+{
+ free(blob->data);
+ free(blob);
+}
+
+/**
* Add some unstructured, fixed-size data to a blob.
*
* \return True unless allocation failed.
disk_cache_put(cache, prog->data->sha1, metadata->data, metadata->size);
- free(metadata);
+ blob_destroy(metadata);
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
_mesa_sha1_format(sha1_buf, prog->data->sha1);
"read_consumes_all_bytes");
expect_equal(false, reader.overrun, "read_does_not_overrun");
- free(blob);
+ blob_destroy(blob);
}
/* Test that data values are written and read with proper alignment. */
"aligned read of intptr_t");
}
- free(blob);
+ blob_destroy(blob);
}
/* Test that we detect overrun. */
expect_equal(0, blob_read_uint32(&reader), "read at overrun");
expect_equal(true, reader.overrun, "overrun flag set");
- free(blob);
+ blob_destroy(blob);
}
/* Test that we can read and write some large objects, (exercising the code in
expect_equal(false, reader.overrun,
"overrun flag not set reading large objects");
- free(blob);
+ blob_destroy(blob);
ralloc_free(ctx);
}