diff options
| author | peter <peter@pmikkelsen.com> | 2026-08-21 16:18:14 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-08-21 16:18:14 +0000 |
| commit | fabbd7590258478f4304ac6cdd9996d4a86eafd9 (patch) | |
| tree | 6665ee5971e2f2e3b49032427b66c2894cefd716 /src/lib/memory.c | |
| parent | 8af7b7fc0a8dbe3502a7cd43c6a10fdcc6013677 (diff) | |
More work on the scanner and tests for it
FossilOrigin-Name: 037c88ce86e1ba3a399c03a27d4c7252b52c2f500bc13f449e19e497b0607880
Diffstat (limited to 'src/lib/memory.c')
| -rw-r--r-- | src/lib/memory.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/memory.c b/src/lib/memory.c index 136c7e6..41ac90d 100644 --- a/src/lib/memory.c +++ b/src/lib/memory.c @@ -18,7 +18,7 @@ alloc(struct memory *m, size_t size, size_t align) size_t alloc_size, adjust; void *p; - ptr = (uintptr_t)m->data; + ptr = ((uintptr_t)m->data) + m->offset; alloc_size = size; if(NEVER(align == 0)) @@ -30,6 +30,7 @@ alloc(struct memory *m, size_t size, size_t align) if((m->size - m->offset) >= alloc_size){ p = m->data+m->offset+alloc_size-size; + assert((((uintptr_t)p) % align) == 0); m->offset += alloc_size; memset(p, 0, size); }else @@ -85,3 +86,19 @@ memory_free_string(struct memory *m, struct string *p) UNUSED_PARAMETER(m); UNUSED_PARAMETER(p); } + +struct token_list * +memory_alloc_token_list(struct memory *m, size_t tokens) +{ + struct token_list *p; + + p = alloc(m, sizeof(struct token_list) + (tokens * sizeof(struct token)), alignof(struct token_list)); + return p; +} + +void +memory_free_token_list(struct memory *m, struct token_list *p) +{ + UNUSED_PARAMETER(m); + UNUSED_PARAMETER(p); +} |