1 #include "utils.h" 2 3 #include <stdlib.h> 4 #include <string.h> 5 6 char** generate_test_sarray(size_t len) 7 { 8 static const char testString[] = "test"; 9 size_t i; 10 char** ret = calloc(len + 1, sizeof(*ret)); 11 if (!ret) 12 return NULL; 13 14 for (i = 0; i < len; ++i) 15 { 16 ret[i] = strdup(testString); 17 if (!ret[i]) 18 goto error; 19 } 20 21 return ret; 22 23 error: 24 for (i = 0; i < len; ++i) 25 { 26 free(ret[i]); 27 } 28 free(ret); 29 30 return NULL; 31 } 32