libwbclient: Add wbcStrDup
authorVolker Lendecke <vl@samba.org>
Sat, 3 Apr 2010 09:59:29 +0000 (11:59 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 19 Apr 2010 12:27:16 +0000 (14:27 +0200)
nsswitch/libwbclient/wbclient.c
nsswitch/libwbclient/wbclient_internal.h

index ea6c24ccc3053a6ec36a78d2dde5e8670a2f26c3..99248710e6dc272cfcff7786819039a715fc269a 100644 (file)
@@ -205,6 +205,20 @@ void wbcFreeMemory(void *p)
        return;
 }
 
+char *wbcStrDup(const char *str)
+{
+       char *result;
+       size_t len;
+
+       len = strlen(str);
+       result = (char *)wbcAllocateMemory(len+1, sizeof(char), NULL);
+       if (result == NULL) {
+               return NULL;
+       }
+       memcpy(result, str, len+1);
+       return result;
+}
+
 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **_details)
 {
        struct wbcLibraryDetails *info;
index 6c59be3fef87cf426127753b557679bfa0240e66..78178cbafe92b03c9619fdbeea6e1bd3545ef741 100644 (file)
@@ -35,4 +35,6 @@ wbcErr wbcRequestResponsePriv(int cmd,
 void *wbcAllocateMemory(size_t nelem, size_t elsize,
                        void (*destructor)(void *ptr));
 
+char *wbcStrDup(const char *str);
+
 #endif      /* _WBCLIENT_INTERNAL_H */