]> git.ipfire.org Git - pakfire.git/commitdiff
util: Use our custom realloc function everywhere else, too
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Oct 2024 11:57:35 +0000 (11:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Oct 2024 11:58:42 +0000 (11:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/progressbar.c
src/libpakfire/string.c
src/libpakfire/xfer.c

index 5472c01413b58650e4d6a6abae73d1f10b3055d1..54c84ce45edfef338b4598dccc9fdeeb2779b930 100644 (file)
@@ -28,6 +28,7 @@
 #include <pakfire/i18n.h>
 #include <pakfire/pakfire.h>
 #include <pakfire/progress.h>
+#include <pakfire/util.h>
 
 #include "progressbar.h"
 #include "terminal.h"
@@ -350,7 +351,7 @@ static int cli_progressbar_add_percentage(struct cli_progressbar* p) {
 static ssize_t cli_progressbar_bar(struct cli_progressbar* p,
                struct cli_progressbar_widget* widget, unsigned int width, void* data) {
        // Allocate or adjust the buffer
-       widget->buffer = realloc(widget->buffer, width + 1);
+       widget->buffer = pakfire_realloc(widget->buffer, width + 1);
 
        // Fail if we could not allocate the buffer
        if (!widget->buffer)
index bf64d2980d2cc8e6810399bd941d0dc91f104048..eba9711648eeefe4091918b5f6473c37c6e90f1d 100644 (file)
@@ -27,6 +27,7 @@
 #include <time.h>
 
 #include <pakfire/string.h>
+#include <pakfire/util.h>
 
 int __pakfire_string_format(char* s, const size_t length, const char* format, ...) {
        va_list args;
@@ -185,7 +186,7 @@ static int pakfire_string_append(char** buffer, const char* s, const size_t l) {
        size_t length = (buffer && *buffer) ? strlen(*buffer) : 0;
 
        // Resize the buffer
-       *buffer = realloc(*buffer, length + l + 1);
+       *buffer = pakfire_realloc(*buffer, length + l + 1);
        if (!*buffer)
                return -errno;
 
index 23df4fbf8d83177953ac38ad77a5a6ff5a6d9ebd..6909c2436286affb0bae6d12021a2e7cc7f2696c 100644 (file)
@@ -948,7 +948,7 @@ static const char* curl_http_version(long v) {
 static int pakfire_xfer_allocate(struct pakfire_xfer* xfer, size_t size) {
 
        // Otherwise, we resize the buffer
-       xfer->buffer.data = realloc(xfer->buffer.data, size);
+       xfer->buffer.data = pakfire_realloc(xfer->buffer.data, size);
        if (!xfer->buffer.data) {
                CTX_ERROR(xfer->ctx, "Could not allocate memory: %m\n");