aboutsummaryrefslogtreecommitdiff
path: root/src/alloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.h')
-rw-r--r--src/alloc.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/alloc.h b/src/alloc.h
index 2c67fb7..79d7c0b 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -7,12 +7,26 @@
#include "common.h"
typedef struct _arena *arena_t;
+typedef struct {
+ void *p;
+ size_t sz;
+} scratch_t;
/* Allocate a buffer of NMEMB elements of size SIZE. If PTR is non-null then
reallocate the buffer it points to. Aborts on out-of-memory or overflow. */
void *bufalloc(void *ptr, size_t nmemb, size_t size)
__attribute__((returns_nonnull, warn_unused_result, alloc_size(2, 3)));
+/* Alloc a buffer of NMEMB elements of size SIZE for one time use. Each
+ time this function is invoked previous allocations are overwritten. */
+void *tmpalloc(scratch_t *s, size_t nmemb, size_t size)
+ __attribute__((returns_nonnull, warn_unused_result, nonnull,
+ alloc_size(2, 3)));
+
+/* Reallocate all memory associated with S */
+void tmpfree(scratch_t *s)
+ __attribute__((nonnull));
+
/* Allocate a buffer of NMEMB elements of size SIZE with alignment ALIGN using
the arena-allocator A. */
void *arena_alloc(arena_t *a, size_t nmemb, size_t size, size_t align)