lib: add string array duplication function

This commit is contained in:
jussi 2019-10-17 16:14:39 +03:00
parent de8e42db81
commit bd61cbe98c
2 changed files with 15 additions and 0 deletions

13
src/lib/tc_common.c Normal file
View File

@ -0,0 +1,13 @@
#include <tc_common.h>
#include <stdlib.h>
#include <string.h>
char **tc_str_arr_dup(int8_t str_count, char **const strings) {
char **ptr_arr = calloc(str_count, sizeof(char*));
for (int8_t i = 0; i < str_count; i++) {
ptr_arr[i] = strdup(strings[i]);
}
return NULL;
}

View File

@ -11,6 +11,8 @@ module_path_def = module_path_def_template.format(get_option('prefix'), get_opti
libtuxclocker = shared_library('libtuxclocker', libtuxclocker = shared_library('libtuxclocker',
['lib/tc_assignable.c', ['lib/tc_assignable.c',
'lib/tc_module.c', 'lib/tc_module.c',
'lib/tc_readable.c',
'lib/tc_common.c',
libtuxclocker_posix_sources], libtuxclocker_posix_sources],
include_directories : incdir, include_directories : incdir,
dependencies : libtuxclocker_posix_libs, dependencies : libtuxclocker_posix_libs,