diff options
Diffstat (limited to 'src/compiler/blob.c')
-rw-r--r-- | src/compiler/blob.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/blob.c b/src/compiler/blob.c index 2e20a11dc0c..a78fcd41a76 100644 --- a/src/compiler/blob.c +++ b/src/compiler/blob.c @@ -52,6 +52,11 @@ grow_to_fit(struct blob *blob, size_t additional) if (blob->size + additional <= blob->allocated) return true; + if (blob->fixed_allocation) { + blob->out_of_memory = true; + return false; + } + if (blob->allocated == 0) to_allocate = BLOB_INITIAL_SIZE; else @@ -105,6 +110,17 @@ blob_init(struct blob *blob) blob->data = NULL; blob->allocated = 0; blob->size = 0; + blob->fixed_allocation = false; + blob->out_of_memory = false; +} + +void +blob_init_fixed(struct blob *blob, void *data, size_t size) +{ + blob->data = data; + blob->allocated = size; + blob->size = 0; + blob->fixed_allocation = true; blob->out_of_memory = false; } |