Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void some_function(char*** arr, const char* s, size_t *arr_len) {
- if (*arr == NULL) {
- *arr = malloc(sizeof(char*));
- (*arr)[0] = strdup(s);
- *arr_len = 1;
- return;
- }
- char** tmp;
- if ( (tmp = realloc( *arr, (*arr_len + 1) * sizeof(char*) )) == NULL) {
- perror("couldnt get more memory.");
- }
- *arr = tmp;
- (*arr)[(*arr_len)++] = strdup(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement