1 2/* note: this routine frees its arguments! */ 3char ** 4my_join (char **np1, char **np2) { 5 int lth1, lth2; 6 char **p, **q, **np; 7 8 if (np1 == NULL) 9 return np2; 10 if (np2 == NULL) 11 return np1; 12 lth1 = lth2 = 0; 13 for (p = np1; *p; p++) 14 lth1++; 15 for (p = np2; *p; p++) 16 lth2++; 17 p = np = (char **) my_malloc((lth1+lth2+1)*sizeof(*np)); 18 q = np1; 19 while(*q) 20 *p++ = *q++; 21 q = np2; 22 while(*q) 23 *p++ = *q++; 24 *p = 0; 25 free(np1); 26 free(np2); 27 return np; 28} 29