]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curlx: drop unused `curlx_saferealloc()`
authorViktor Szakats <commit@vsz.me>
Tue, 3 Feb 2026 13:10:02 +0000 (14:10 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 3 Feb 2026 14:13:37 +0000 (15:13 +0100)
Unused since 67ae101666f1023263c475b88b266bc9b5e658c0 #19949

Closes #20504

lib/curlx/dynbuf.c
lib/curlx/strdup.c
lib/curlx/strdup.h

index 22062c3bfa5c39957dd1eb5205577ab88056bf3d..a96b2a5974c59a19df2d39058784bdda019ff8bb 100644 (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);
index 0d349e5c8a6640745b05209d8adad6ad0d1d9897..59031bcf13e2da709140e9cfc0e14132d730b664 100644 (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;
-}
index 420385dcd2cf4c8cd06e7b4191d5da24540c59ce..eac4039b38b5664405455cafc68678a550cc1c5d 100644 (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 */