From 5280f9a0cd1f9ba200422ebba65d1e0133410995 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 13 Sep 2014 09:43:21 -0700 Subject: Initial. --- src/join.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/join.c (limited to 'src/join.c') diff --git a/src/join.c b/src/join.c new file mode 100644 index 0000000..1461ace --- /dev/null +++ b/src/join.c @@ -0,0 +1,28 @@ + +/* note: this routine frees its arguments! */ +char ** +my_join (char **np1, char **np2) { + int lth1, lth2; + char **p, **q, **np; + + if (np1 == NULL) + return np2; + if (np2 == NULL) + return np1; + lth1 = lth2 = 0; + for (p = np1; *p; p++) + lth1++; + for (p = np2; *p; p++) + lth2++; + p = np = (char **) my_malloc((lth1+lth2+1)*sizeof(*np)); + q = np1; + while(*q) + *p++ = *q++; + q = np2; + while(*q) + *p++ = *q++; + *p = 0; + free(np1); + free(np2); + return np; +} -- cgit v1.2.3