s/malloc/xmalloc/ s/calloc/xcalloc/ s/realloc/realloc/
[oweals/opkg-lede.git] / libopkg / file_util.c
index b867df76a2b0a23dc29a51c40a42f5b0f7ccec9a..902b8c935477d35e7da8a26434f2d087cfa4eae4 100644 (file)
@@ -75,11 +75,7 @@ char *file_read_line_alloc(FILE *file)
        buf_len = strlen(buf);
        if (line) {
            line_size += buf_len;
-           line = realloc(line, line_size);
-           if (line == NULL) {
-               fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
-               break;
-           }
+           line = xrealloc(line, line_size);
            strcat(line, buf);
        } else {
            line_size = buf_len + 1;
@@ -147,11 +143,7 @@ char *file_md5sum_alloc(const char *file_name)
     char *md5sum_hex;
     unsigned char md5sum_bin[md5sum_bin_len];
 
-    md5sum_hex = calloc(1, md5sum_hex_len + 1);
-    if (md5sum_hex == NULL) {
-       fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
-       return NULL;
-    }
+    md5sum_hex = xcalloc(1, md5sum_hex_len + 1);
 
     file = fopen(file_name, "r");
     if (file == NULL) {
@@ -200,11 +192,7 @@ char *file_sha256sum_alloc(const char *file_name)
     char *sha256sum_hex;
     unsigned char sha256sum_bin[sha256sum_bin_len];
 
-    sha256sum_hex = calloc(1, sha256sum_hex_len + 1);
-    if (sha256sum_hex == NULL) {
-       fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
-       return NULL;
-    }
+    sha256sum_hex = xcalloc(1, sha256sum_hex_len + 1);
 
     file = fopen(file_name, "r");
     if (file == NULL) {