From 956efffddc52fdcf034df7aed984e738c3e55007 Mon Sep 17 00:00:00 2001 From: Tadashi Saito Date: Sun, 13 Oct 2024 20:31:53 +0900 Subject: [PATCH] Add a pattern for const char *. --- scary.c | 4 ++++ scary.h | 3 ++- testlib.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scary.c b/scary.c index 683d458..7dc786c 100644 --- a/scary.c +++ b/scary.c @@ -127,6 +127,10 @@ DEF_PUSH_VARIANT_T_PTR(uint32) DEF_PUSH_VARIANT_T_PTR(uint64) DEF_PUSH_VARIANT1_PTR(char) DEF_PUSH_VARIANT1_PTR(void) +void scary_push_ccharp(const char ***p, const char *elem) +{ + scary_push_ptr(p, elem); +} void scary_pop(void *p) { diff --git a/scary.h b/scary.h index ee35fde..39d0d70 100644 --- a/scary.h +++ b/scary.h @@ -25,7 +25,7 @@ size_t scary_length(const void *ary); uint32_t: scary_push_uint32, \ uint64_t: scary_push_uint64, \ char *: scary_push_charp, \ - const char *: scary_push_charp, \ + const char *: scary_push_ccharp, \ int8_t *: scary_push_int8p, \ int16_t *: scary_push_int16p, \ int32_t *: scary_push_int32, \ @@ -45,6 +45,7 @@ void scary_push_uint8(uint8_t **, uint8_t); void scary_push_uint16(uint16_t **, uint16_t); void scary_push_uint32(uint32_t **, uint32_t); void scary_push_uint64(uint64_t **, uint64_t); +void scary_push_ccharp(const char ***, const char *); void scary_push_charp(char ***, const char *); void scary_push_voidp(void ***, const void *); void scary_push_int8p(int8_t ***, const int8_t *); diff --git a/testlib.c b/testlib.c index 16b67ed..7c67abc 100644 --- a/testlib.c +++ b/testlib.c @@ -46,7 +46,7 @@ Test(libscary, push_ptr) { scary_free(a); char **b = scary_new(sizeof(char *)); - const char *l[] = { "foo", "bar" }; + char *l[] = { "foo", "bar" }; scary_push(&b, l[0]); scary_push(&b, l[1]); cr_expect(eq(sz, 2, scary_length(b)));