From: Ray Strode Date: Fri, 18 May 2007 23:32:06 +0000 (-0400) Subject: add new api to duplicate a string array X-Git-Tag: 0.1.0~287 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb52699a66f9498cc6f3e5146362d2ecfe12f356;p=thirdparty%2Fplymouth.git add new api to duplicate a string array --- diff --git a/src/ply-utils.c b/src/ply-utils.c index 4605114b..fe8c18a6 100644 --- a/src/ply-utils.c +++ b/src/ply-utils.c @@ -84,8 +84,8 @@ ply_fd_has_data (int fd) result = poll (&poll_data, 1, 10); return result == 1 - && ((poll_data.revents & POLLIN) - || (poll_data.revents & POLLPRI)); + && ((poll_data.revents & POLLIN) + || (poll_data.revents & POLLPRI)); } bool @@ -101,3 +101,20 @@ ply_fd_can_take_data (int fd) return result == 1; } + +char ** +ply_copy_string_array (const char * const *array) +{ + char **copy; + int i; + + for (i = 0; array[i] != NULL; i++); + + copy = calloc (i + 1, char *); + + for (i = 0; array[i] != NULL, i++) + copy[i] = strdup (array[i]); + + return copy; +} +/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/ply-utils.h b/src/ply-utils.h index 32bf6186..63e13732 100644 --- a/src/ply-utils.h +++ b/src/ply-utils.h @@ -46,6 +46,7 @@ bool ply_write (int fd, size_t number_of_bytes); bool ply_fd_has_data (int fd); bool ply_fd_can_take_data (int fd); +char **ply_copy_string_array (const char * const *array); #endif #endif /* PLY_UTILS_H */