lib: rename Curl_strndup to Curl_memdup0 to avoid misunderstanding

Since the copy does not stop at a null byte, let's not call it anything
that makes you think it works like the common strndup() function.

Based on feedback from Jay Satiro, Stefan Eissing and Patrick Monnerat

Closes #12490
This commit is contained in:
Daniel Stenberg 2023-12-08 14:27:29 +01:00
parent 6d8dc2f636
commit 7c992dd9f8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
15 changed files with 27 additions and 27 deletions

View file

@ -1231,7 +1231,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
u->fragment = Curl_dyn_ptr(&enc);
}
else {
u->fragment = Curl_strndup(fragment + 1, fraglen - 1);
u->fragment = Curl_memdup0(fragment + 1, fraglen - 1);
if(!u->fragment) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
@ -1260,7 +1260,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
u->query = Curl_dyn_ptr(&enc);
}
else {
u->query = Curl_strndup(query + 1, qlen - 1);
u->query = Curl_memdup0(query + 1, qlen - 1);
if(!u->query) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
@ -1294,7 +1294,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
}
else {
if(!u->path) {
u->path = Curl_strndup(path, pathlen);
u->path = Curl_memdup0(path, pathlen);
if(!u->path) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
@ -1592,7 +1592,7 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
if(ptr) {
size_t partlen = strlen(ptr);
size_t i = 0;
*part = Curl_strndup(ptr, partlen);
*part = Curl_memdup0(ptr, partlen);
if(!*part)
return CURLUE_OUT_OF_MEMORY;
if(plusdecode) {