Skip to content

Commit

Permalink
Add a pattern for const char *.
Browse files Browse the repository at this point in the history
  • Loading branch information
tadd committed Oct 13, 2024
1 parent db1935e commit 956efff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions scary.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion scary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand All @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion testlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit 956efff

Please sign in to comment.