diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-09-13 09:43:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-09-13 09:43:21 -0700 |
commit | 5280f9a0cd1f9ba200422ebba65d1e0133410995 (patch) | |
tree | bf85ce4e320a769d7e0903ff52ccfde13a422666 /src/join.c | |
download | man-5280f9a0cd1f9ba200422ebba65d1e0133410995.tar.gz man-5280f9a0cd1f9ba200422ebba65d1e0133410995.tar.bz2 man-5280f9a0cd1f9ba200422ebba65d1e0133410995.zip |
Initial.man-1.6g
Diffstat (limited to 'src/join.c')
-rw-r--r-- | src/join.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; +} |