summaryrefslogtreecommitdiff
path: root/ares_strdup.c
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-11-09 11:18:45 +0900
committerYu Jiung <jiung.yu@samsung.com>2016-11-09 11:18:55 +0900
commiteb886f120599b2a184db20b527db6dfdfcb7852e (patch)
treeb49d8075742c4a27b237fa183cb68670e421d398 /ares_strdup.c
parentb6627e2c19506bd30328969ea8aab73fa0945f36 (diff)
downloadc-ares-eb886f120599b2a184db20b527db6dfdfcb7852e.tar.gz
c-ares-eb886f120599b2a184db20b527db6dfdfcb7852e.tar.bz2
c-ares-eb886f120599b2a184db20b527db6dfdfcb7852e.zip
Imported Upstream version 1.11.0upstream/1.11.0
Change-Id: I238c24b75a10aa902d9bc4076ed68b76b5e2a750
Diffstat (limited to 'ares_strdup.c')
-rw-r--r--ares_strdup.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/ares_strdup.c b/ares_strdup.c
index 1804327..0c3dcff 100644
--- a/ares_strdup.c
+++ b/ares_strdup.c
@@ -17,26 +17,33 @@
#include "ares_setup.h"
#include "ares_strdup.h"
+#include "ares.h"
+#include "ares_private.h"
-#ifndef HAVE_STRDUP
char *ares_strdup(const char *s1)
{
- size_t sz;
- char * s2;
+#ifdef HAVE_STRDUP
+ if (ares_malloc == malloc)
+ return strdup(s1);
+ else
+#endif
+ {
+ size_t sz;
+ char * s2;
- if(s1) {
- sz = strlen(s1);
- if(sz < (size_t)-1) {
- sz++;
- if(sz < ((size_t)-1) / sizeof(char)) {
- s2 = malloc(sz * sizeof(char));
- if(s2) {
- memcpy(s2, s1, sz * sizeof(char));
- return s2;
+ if(s1) {
+ sz = strlen(s1);
+ if(sz < (size_t)-1) {
+ sz++;
+ if(sz < ((size_t)-1) / sizeof(char)) {
+ s2 = ares_malloc(sz * sizeof(char));
+ if(s2) {
+ memcpy(s2, s1, sz * sizeof(char));
+ return s2;
+ }
}
}
}
+ return (char *)NULL;
}
- return (char *)NULL;
}
-#endif