aboutsummaryrefslogtreecommitdiff
path: root/lib/strdup.c
diff options
context:
space:
mode:
authorSadaf Ebrahimi <sadafebrahimi@google.com>2024-02-20 18:53:58 +0000
committerSadaf Ebrahimi <sadafebrahimi@google.com>2024-02-20 18:55:51 +0000
commit94577271ee81d3399bec0328cc6a27688029edec (patch)
tree1b01132e15db02538dcf10922559df5a286d1cd6 /lib/strdup.c
parent97598f1763810e446ff21ec60fb0b222097b32c6 (diff)
parent5ce164e0e9290c96eb7d502173426c0a135ec008 (diff)
downloadcurl-94577271ee81d3399bec0328cc6a27688029edec.tar.gz
Upgrade curl to curl-8_6_0
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/curl For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I083147dff18fe11adc3131953c5ad4a3e14433fe
Diffstat (limited to 'lib/strdup.c')
-rw-r--r--lib/strdup.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/strdup.c b/lib/strdup.c
index 07a61391a..299c9cc36 100644
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -26,7 +26,7 @@
#include <curl/curl.h>
-#ifdef WIN32
+#ifdef _WIN32
#include <wchar.h>
#endif
@@ -56,7 +56,7 @@ char *Curl_strdup(const char *str)
}
#endif
-#ifdef WIN32
+#ifdef _WIN32
/***************************************************************************
*
* Curl_wcsdup(source)
@@ -101,6 +101,26 @@ void *Curl_memdup(const void *src, size_t length)
/***************************************************************************
*
+ * Curl_memdup0(source, length)
+ *
+ * Copies the 'source' string to a newly allocated buffer (that is returned).
+ * Copies 'length' bytes then adds a null terminator.
+ *
+ * Returns the new pointer or NULL on failure.
+ *
+ ***************************************************************************/
+void *Curl_memdup0(const char *src, size_t length)
+{
+ char *buf = malloc(length + 1);
+ if(!buf)
+ return NULL;
+ memcpy(buf, src, length);
+ buf[length] = 0;
+ return buf;
+}
+
+/***************************************************************************
+ *
* Curl_saferealloc(ptr, size)
*
* Does a normal realloc(), but will free the data pointer if the realloc