#include <string.h>
#include "main/macros.h"
-#include "util/ralloc.h"
#include "blob.h"
#define BLOB_INITIAL_SIZE 4096
to_allocate = MAX2(to_allocate, blob->allocated + additional);
- new_data = reralloc_size(blob, blob->data, to_allocate);
+ new_data = realloc(blob->data, to_allocate);
if (new_data == NULL)
return false;
}
struct blob *
-blob_create(void *mem_ctx)
+blob_create()
{
- struct blob *blob;
-
- blob = ralloc(mem_ctx, struct blob);
+ struct blob *blob = (struct blob *) malloc(sizeof(struct blob));
if (blob == NULL)
return NULL;
};
/**
- * Create a new, empty blob, belonging to \mem_ctx.
+ * Create a new, empty blob.
*
* \return The new blob, (or NULL in case of allocation failure).
*/
struct blob *
-blob_create(void *mem_ctx);
+blob_create(void);
/**
* Add some unstructured, fixed-size data to a blob.
if (*prog->data->sha1 == 0)
return;
- struct blob *metadata = blob_create(NULL);
+ struct blob *metadata = blob_create();
write_uniforms(metadata, prog);
disk_cache_put(cache, prog->data->sha1, metadata->data, metadata->size);
- ralloc_free(metadata);
+ free(metadata);
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
fprintf(stderr, "putting program metadata in cache: %s\n",
static void
test_write_and_read_functions (void)
{
- void *ctx = ralloc_context(NULL);
struct blob *blob;
struct blob_reader reader;
uint8_t *reserved;
size_t str_offset, uint_offset;
uint8_t reserve_buf[sizeof(reserve_test_str)];
- blob = blob_create(ctx);
+ blob = blob_create();
/*** Test blob by writing one of every possible kind of value. */
"read_consumes_all_bytes");
expect_equal(false, reader.overrun, "read_does_not_overrun");
- ralloc_free(ctx);
+ free(blob);
}
/* Test that data values are written and read with proper alignment. */
static void
test_alignment(void)
{
- void *ctx = ralloc_context(NULL);
struct blob *blob;
struct blob_reader reader;
uint8_t bytes[] = "ABCDEFGHIJKLMNOP";
size_t delta, last, num_bytes;
- blob = blob_create(ctx);
+ blob = blob_create();
/* First, write an intptr value to the blob and capture that size. This is
* the expected offset between any pair of intptr values (if written with
"aligned read of intptr_t");
}
- ralloc_free(ctx);
+ free(blob);
}
/* Test that we detect overrun. */
static void
test_overrun(void)
{
- void *ctx =ralloc_context(NULL);
struct blob *blob;
struct blob_reader reader;
uint32_t value = 0xdeadbeef;
- blob = blob_create(ctx);
+ blob = blob_create();
blob_write_uint32(blob, value);
expect_equal(0, blob_read_uint32(&reader), "read at overrun");
expect_equal(true, reader.overrun, "overrun flag set");
- ralloc_free(ctx);
+ free(blob);
}
/* Test that we can read and write some large objects, (exercising the code in
size_t i;
char *buf;
- blob = blob_create(ctx);
+ blob = blob_create();
/* Initialize our buffer. */
buf = ralloc_size(ctx, size);
expect_equal(false, reader.overrun,
"overrun flag not set reading large objects");
+ free(blob);
ralloc_free(ctx);
}