From 480538737a8a9be074a1848f2e52cf2d1ff4709f Mon Sep 17 00:00:00 2001 From: graham.gower Date: Wed, 04 Nov 2009 23:20:09 -0500 Subject: s/malloc/xmalloc/ s/calloc/xcalloc/ s/realloc/realloc/ And redundant error checking removed from the places where allocation failures were actually checked. git-svn-id: http://opkg.googlecode.com/svn/trunk@259 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- (limited to 'libopkg/file_util.c') diff --git a/libopkg/file_util.c b/libopkg/file_util.c index b867df7..902b8c9 100644 --- a/libopkg/file_util.c +++ b/libopkg/file_util.c @@ -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) { -- cgit v0.9.1