Skip to content

Commit

Permalink
Privatize scary_push_ref.
Browse files Browse the repository at this point in the history
  • Loading branch information
tadd committed Oct 12, 2024
1 parent 1017d73 commit 345f3a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scary.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ size_t scary_length(const void *p)
return ary->length;
}

void scary_push_ref(void *p, const void *elem)
static void scary_push_ref(void *p, const void *elem)
{
void **pp = p;
Scary *ary = get(*pp);
Expand Down
1 change: 0 additions & 1 deletion scary.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
void *scary_new(size_t size);
void scary_free(void *ary);
size_t scary_length(const void *ary);
void scary_push_ref(void *ary, const void *elem);
#ifdef __APPLE__
#define scary_push_archdep_pattern() unsigned long: scary_push_uint64,
#else
Expand Down
12 changes: 6 additions & 6 deletions testlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

#include "scary.h"

Test(libscary, push_ref_and_length) {
int *a = scary_new(sizeof(int));
Test(libscary, push_and_length) {
int32_t *a = scary_new(sizeof(int32_t));
cr_expect(eq(sz, 0, scary_length(a)));

int l[] = { 1, -2, 3, -5, 7, -11 }, *p = l;
int32_t l[] = { 1, -2, 3, -5, 7, -11 }, *p = l;
const size_t n = sizeof(l)/sizeof(*l);
for (size_t i = 0; i < n; i++)
scary_push_ref(&a, p++);
scary_push_int32(&a, *p++);

cr_expect(eq(sz, n, scary_length(a)));
cr_expect(eq(int, 1, a[0]));
cr_expect(eq(int[n], l, a));
cr_expect(eq(i32, 1, a[0]));
cr_expect(eq(i32[n], l, a));

scary_free(a);
}
Expand Down

0 comments on commit 345f3a4

Please sign in to comment.