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