ind.c (392B)
1 /* 2 * Copy me if you can. 3 * by 20h 4 */ 5 6 #include <unistd.h> 7 #include <stdio.h> 8 #include <stdlib.h> 9 #include <string.h> 10 #include "ind.h" 11 12 void * 13 greallocz(void *p, int l, int z) 14 { 15 16 p = realloc(p, l); 17 if(p == nil) 18 exit(1); 19 if(z > 0) 20 memset(p, 0, l); 21 22 return p; 23 } 24 25 void * 26 gmemdup(void *p, int l) 27 { 28 char *ret; 29 30 ret = greallocz(nil, l, 2); 31 memmove(ret, p, l); 32 33 return (void *)ret; 34 } 35