summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 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 */