summaryrefslogtreecommitdiff
path: root/tests/aplwc_utf8.c
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-08-30 20:52:43 +0000
committerpeter <peter@pmikkelsen.com>2026-08-30 20:52:43 +0000
commit729964bea692f9683860978b89848784a7fc2f46 (patch)
treeba5b37a61206142fce18214c7af341ac837a7923 /tests/aplwc_utf8.c
parent04827577ea502a9f0edc69e00e008751c8119cbc (diff)
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
Diffstat (limited to 'tests/aplwc_utf8.c')
-rw-r--r--tests/aplwc_utf8.c25
1 files changed, 23 insertions, 2 deletions
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 <stdlib.h>
+#include <string.h>
#include <aplwc.h>
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;