diff options
author | Volker Lendecke <vl@samba.org> | 2010-04-03 13:37:01 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-04-19 14:27:17 +0200 |
commit | ab892389db3d7e42e617d38f24c1dff73d608bec (patch) | |
tree | 2419b5aeabfbf25fe60caaf589f41c861c782e14 | |
parent | 250bea02b586219275efc87d65fbae32b867ba86 (diff) | |
download | samba-ab892389db3d7e42e617d38f24c1dff73d608bec.tar.gz samba-ab892389db3d7e42e617d38f24c1dff73d608bec.tar.bz2 samba-ab892389db3d7e42e617d38f24c1dff73d608bec.zip |
libwbclient: Add wbcAllocateStringArray
-rw-r--r-- | nsswitch/libwbclient/wbclient.c | 16 | ||||
-rw-r--r-- | nsswitch/libwbclient/wbclient_internal.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/nsswitch/libwbclient/wbclient.c b/nsswitch/libwbclient/wbclient.c index 99248710e6..fa51cbd8cb 100644 --- a/nsswitch/libwbclient/wbclient.c +++ b/nsswitch/libwbclient/wbclient.c @@ -219,6 +219,22 @@ char *wbcStrDup(const char *str) return result; } +static void wbcStringArrayDestructor(void *ptr) +{ + char **p = (char **)ptr; + while (*p != NULL) { + free(*p); + p += 1; + } +} + +const char **wbcAllocateStringArray(int num_strings) +{ + return (const char **)wbcAllocateMemory( + num_strings + 1, sizeof(const char *), + wbcStringArrayDestructor); +} + wbcErr wbcLibraryDetails(struct wbcLibraryDetails **_details) { struct wbcLibraryDetails *info; diff --git a/nsswitch/libwbclient/wbclient_internal.h b/nsswitch/libwbclient/wbclient_internal.h index 78178cbafe..31f413057e 100644 --- a/nsswitch/libwbclient/wbclient_internal.h +++ b/nsswitch/libwbclient/wbclient_internal.h @@ -36,5 +36,6 @@ void *wbcAllocateMemory(size_t nelem, size_t elsize, void (*destructor)(void *ptr)); char *wbcStrDup(const char *str); +const char **wbcAllocateStringArray(int num_strings); #endif /* _WBCLIENT_INTERNAL_H */ |