diff options
| author | peter <peter@pmikkelsen.com> | 2026-08-31 20:22:47 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-08-31 20:22:47 +0000 |
| commit | 8b0beb9e6a57c1d4f1e7b0b06523dd0fc538771a (patch) | |
| tree | 9bb8b689020d5098ea3c31251ddcd2fbb9524a7c /src/lib/syntax.c | |
| parent | d361abaeb8dcf19446a9322737ea600b22568a5b (diff) | |
| parent | f9f9b10c1d17077632d7a09e447e629b8d33b23d (diff) | |
Merge memory manager changes into trunk
FossilOrigin-Name: af583e3ba70b2d10efdead8e03a42fe5c1b94d6b387522833606c138b527a653
Diffstat (limited to 'src/lib/syntax.c')
| -rw-r--r-- | src/lib/syntax.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/lib/syntax.c b/src/lib/syntax.c index 395c75e..ae52343 100644 --- a/src/lib/syntax.c +++ b/src/lib/syntax.c @@ -240,17 +240,17 @@ scan_string(struct aplwc *aplwc, struct string *text, int oneline) struct token_list *tokens; size_t n, i; + MEMPTRS(aplwc, 1); + MEMPTR(0, text); + + tokens = NULL; rc = check(text, &n); - if(rc != APLWC_OK){ - aplwc->last_error = rc; - return NULL; - } + if(rc != APLWC_OK) + goto end; - tokens = memory_alloc_token_list(&aplwc->memory, n); - if(tokens == NULL){ - aplwc->last_error = APLWC_OUT_OF_MEMORY; - return NULL; - } + tokens = memory_alloc_token_list(aplwc, n); + if(tokens == NULL) + goto end; tokens->text = text; tokens->length = n; scan(text, tokens); @@ -261,12 +261,16 @@ scan_string(struct aplwc *aplwc, struct string *text, int oneline) for(i++; i < n; i++){ if(tokens->tokens[i].tag != TOKEN_TAG_NEWLINE){ - memory_free_token_list(&aplwc->memory, tokens); - return NULL; + rc = APLWC_INVALID_SYNTAX; + tokens = NULL; + goto end; } } } +end: + aplwc->last_error = rc; + MEMPTRS_EXIT(aplwc); return tokens; } |