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 /tests/aplwc_read.c | |
| parent | d361abaeb8dcf19446a9322737ea600b22568a5b (diff) | |
| parent | f9f9b10c1d17077632d7a09e447e629b8d33b23d (diff) | |
Merge memory manager changes into trunk
FossilOrigin-Name: af583e3ba70b2d10efdead8e03a42fe5c1b94d6b387522833606c138b527a653
Diffstat (limited to 'tests/aplwc_read.c')
| -rw-r--r-- | tests/aplwc_read.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/aplwc_read.c b/tests/aplwc_read.c index c54f598..d090494 100644 --- a/tests/aplwc_read.c +++ b/tests/aplwc_read.c @@ -1,18 +1,38 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <aplwc.h> +static void * +my_alloc(size_t min, size_t max, size_t *actual) +{ + (void)max; + + *actual = min; + return malloc(min); +} + +static void +my_dealloc(void *p) +{ + free(p); +} + int main(int argc, char *argv[]) { - uint8_t data[APLWC_MIN_MEM+1000]; + struct aplwc_fns fns; char *input; struct aplwc *aplwc; - struct aplwc_line *line; + AplwcLine line; enum aplwc_rc ret; FILE *f; long input_size; + memset(&fns, 0, sizeof(fns)); + fns.alloc = my_alloc; + fns.dealloc = my_dealloc; + if(argc != 2) return 1; @@ -33,12 +53,12 @@ main(int argc, char *argv[]) return 1; input[input_size] = 0; - ret = aplwc_new(&aplwc, data, sizeof(data)); + aplwc = aplwc_new(fns, &ret); if(ret) return 1; line = aplwc_read(aplwc, input); - if((line == NULL) && (aplwc_last_error(aplwc) != APLWC_OUT_OF_MEMORY)) + if((!aplwc_valid_line(line)) && (aplwc_last_error(aplwc) != APLWC_OUT_OF_MEMORY)) return 1; aplwc_free_line(line); aplwc_destroy(aplwc); |