From 29479e2c50d41f29b5e21ffcb16416887aa693d2 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 30 Aug 2026 13:34:36 +0000 Subject: Remove APLWC_MIN_MEM constant, and APLWC_MEM environment variable FossilOrigin-Name: affcf2ab9c573820c77778abfb4769fad8a30ce457411b02a9528470994c7a6b --- tests/aplwc_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/aplwc_utf8.c') diff --git a/tests/aplwc_utf8.c b/tests/aplwc_utf8.c index b97b978..b950580 100644 --- a/tests/aplwc_utf8.c +++ b/tests/aplwc_utf8.c @@ -17,7 +17,7 @@ uint8_t good5[] = {0xef,0xbb,0xbf,0xf0,0xa3,0x8e,0xb4,0}; int main(void) { - uint8_t data[APLWC_MIN_MEM+64000]; + uint8_t data[64000]; struct aplwc *aplwc; struct aplwc_line *line; enum aplwc_rc ret; -- cgit v1.2.3 From 729964bea692f9683860978b89848784a7fc2f46 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 30 Aug 2026 20:52:43 +0000 Subject: Still a lot to be done, but I'm going to bed. Two remaining big issues: * aplwc (the parameter passed "everywhere") - should it move or not? * values returned from the public API should not move. FossilOrigin-Name: 31ab3154b8f3d5ac167218496e9e204324bf0ac9d36b7bada8fe2a6c8f93d51c --- tests/aplwc_utf8.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/aplwc_utf8.c') diff --git a/tests/aplwc_utf8.c b/tests/aplwc_utf8.c index b950580..4f9f2a4 100644 --- a/tests/aplwc_utf8.c +++ b/tests/aplwc_utf8.c @@ -1,3 +1,5 @@ +#include +#include #include uint8_t bad1[] = {0xff,0}; @@ -14,12 +16,27 @@ uint8_t good3[] = {0xed,0x95,0x9c,0xea,0xb5,0xad,0xec,0x96,0xb4,0}; uint8_t good4[] = {0xe6,0x97,0xa5,0xe6,0x9c,0xac,0xe8,0xaa,0x9e,0}; uint8_t good5[] = {0xef,0xbb,0xbf,0xf0,0xa3,0x8e,0xb4,0}; +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(void) { - uint8_t data[64000]; struct aplwc *aplwc; struct aplwc_line *line; + struct aplwc_fns fns; enum aplwc_rc ret; size_t i; @@ -41,7 +58,11 @@ main(void) good5 }; - ret = aplwc_new(&aplwc, data, sizeof(data)); + memset(&fns, 0, sizeof(fns)); + fns.alloc = my_alloc; + fns.dealloc = my_dealloc; + + ret = aplwc_new(&aplwc, fns); if(ret) return 1; -- cgit v1.2.3 From 7f7a2fb4fb23433e7be3d6953725690c8ea958d2 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 31 Aug 2026 19:44:56 +0000 Subject: The objects returned to the user are now integer-based references, not actual pointers. This means the aplwc internals can update those pointers without the user noticing. FossilOrigin-Name: 654c7d0ec85da295a7fb6ed381500410686b280f342fa81a30481f5e9a20c58a --- tests/aplwc_utf8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/aplwc_utf8.c') diff --git a/tests/aplwc_utf8.c b/tests/aplwc_utf8.c index 4f9f2a4..367db5d 100644 --- a/tests/aplwc_utf8.c +++ b/tests/aplwc_utf8.c @@ -35,7 +35,7 @@ int main(void) { struct aplwc *aplwc; - struct aplwc_line *line; + AplwcLine line; struct aplwc_fns fns; enum aplwc_rc ret; size_t i; @@ -62,13 +62,13 @@ main(void) fns.alloc = my_alloc; fns.dealloc = my_dealloc; - ret = aplwc_new(&aplwc, fns); + aplwc = aplwc_new(fns, &ret); if(ret) return 1; for(i = 0; i < (sizeof(bad_tests)/sizeof(*bad_tests)); i++){ line = aplwc_read(aplwc, (char *)bad_tests[i]); - if(line != NULL) + if(aplwc_valid_line(line)) return 1; if(aplwc_last_error(aplwc) != APLWC_INVALID_UTF8) return 1; @@ -77,7 +77,7 @@ main(void) for(i = 0; i < (sizeof(good_tests)/sizeof(*good_tests)); i++){ line = aplwc_read(aplwc, (char *)good_tests[i]); - if((line == NULL) && (aplwc_last_error(aplwc) == APLWC_INVALID_UTF8)) + if((!aplwc_valid_line(line)) && (aplwc_last_error(aplwc) == APLWC_INVALID_UTF8)) return 1; aplwc_free_line(line); } -- cgit v1.2.3