curlx: drop unused curlx_saferealloc()

Unused since 67ae101666 #19949

Closes #20504
This commit is contained in:
Viktor Szakats 2026-02-03 14:10:02 +01:00
parent 31a4f415af
commit 5bdbad87c5
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 0 additions and 26 deletions

View File

@ -102,8 +102,6 @@ static CURLcode dyn_nappend(struct dynbuf *s,
}
if(a != s->allc) {
/* this logic is not using curlx_saferealloc() to make the tool not have to
include that as well when it uses this code */
void *p = curlx_realloc(s->bufr, a);
if(!p) {
curlx_dyn_free(s);

View File

@ -112,26 +112,3 @@ void *curlx_memdup0(const char *src, size_t length)
buf[length] = 0;
return buf;
}
/***************************************************************************
*
* curlx_saferealloc(ptr, size)
*
* Does a normal curlx_realloc(), but will free the data pointer if the realloc
* fails. If 'size' is non-zero, it will free the data and return a failure.
*
* This convenience function is provided and used to help us avoid a common
* mistake pattern when we could pass in a zero, catch the NULL return and end
* up free'ing the memory twice.
*
* Returns the new pointer or NULL on failure.
*
***************************************************************************/
void *curlx_saferealloc(void *ptr, size_t size)
{
void *datap = curlx_realloc(ptr, size);
if(size && !datap)
/* only free 'ptr' if size was non-zero */
curlx_free(ptr);
return datap;
}

View File

@ -32,5 +32,4 @@ char *curlx_strdup_low(const char *str);
#endif
void *curlx_memdup(const void *src, size_t buffer_length);
void *curlx_memdup0(const char *src, size_t length);
void *curlx_saferealloc(void *ptr, size_t size);
#endif /* HEADER_CURLX_STRDUP_H */