summaryrefslogtreecommitdiff
path: root/nsswitch/libwbclient
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-04-03 13:37:01 +0200
committerVolker Lendecke <vl@samba.org>2010-04-19 14:27:17 +0200
commitab892389db3d7e42e617d38f24c1dff73d608bec (patch)
tree2419b5aeabfbf25fe60caaf589f41c861c782e14 /nsswitch/libwbclient
parent250bea02b586219275efc87d65fbae32b867ba86 (diff)
downloadsamba-ab892389db3d7e42e617d38f24c1dff73d608bec.tar.gz
libwbclient: Add wbcAllocateStringArray
Diffstat (limited to 'nsswitch/libwbclient')
-rw-r--r--nsswitch/libwbclient/wbclient.c16
-rw-r--r--nsswitch/libwbclient/wbclient_internal.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/nsswitch/libwbclient/wbclient.c b/nsswitch/libwbclient/wbclient.c
index 99248710e6d..fa51cbd8cb7 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 78178cbafe9..31f413057e0 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 */