From 13ceb583b892ecbe1094e473c058a6ff18ad0efb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 21 Apr 2020 13:47:04 +0200 Subject: defining GNUNET_array_concatenate() for #6190 --- src/util/test_common_allocation.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/test_common_allocation.c b/src/util/test_common_allocation.c index e2fc29e82..a24af7124 100644 --- a/src/util/test_common_allocation.c +++ b/src/util/test_common_allocation.c @@ -27,7 +27,7 @@ static int -check () +check (void) { #define MAX_TESTVAL 1024 char *ptrs[MAX_TESTVAL]; @@ -134,6 +134,28 @@ check () } +static int +check2 (void) +{ + char *a1 = NULL; + unsigned int a1_len = 0; + const char *a2 = "test"; + + GNUNET_array_append (a1, + a1_len, + 'x'); + GNUNET_array_concatenate (a1, + a1_len, + a2, + 4); + GNUNET_assert (0 == strncmp ("xtest", + a1, + 5)); + GNUNET_assert (5 == a1_len); + return 0; +} + + int main (int argc, char *argv[]) { @@ -142,7 +164,7 @@ main (int argc, char *argv[]) GNUNET_log_setup ("test-common-allocation", "WARNING", NULL); - ret = check (); + ret = check () | check2 (); if (ret != 0) fprintf (stderr, "ERROR %d.\n", -- cgit v1.2.3