fix index in tc_str_arr_dup

This commit is contained in:
jussi 2019-10-22 21:29:16 +03:00
parent 42421e11e6
commit f8d0dbb7b8

View File

@ -3,11 +3,18 @@
#include <stdlib.h>
#include <string.h>
char **tc_str_arr_dup(int8_t str_count, char **const strings) {
char **tc_str_arr_dup(uint16_t str_count, char **const strings) {
char **ptr_arr = calloc(str_count, sizeof(char*));
for (int8_t i = 0; i < str_count; i++) {
for (uint16_t i = 0; i < str_count; i++) {
ptr_arr[i] = strdup(strings[i]);
}
return NULL;
return ptr_arr;
}
void tc_str_arr_free(uint16_t str_count, char **strings) {
for (uint16_t i = 0; i < str_count; i++) {
free(strings[i]);
}
free(strings);
}