summaryrefslogtreecommitdiffstats
path: root/mount/lomount.c
diff options
context:
space:
mode:
authorTobias Klauser2010-08-11 23:12:07 +0200
committerKarel Zak2010-08-20 13:05:21 +0200
commit9695a7c653c5e1871f7bb78fa0e6ec8d4e74a83a (patch)
treed8a53c582ef57ca81093f9ba13a411b960dac828 /mount/lomount.c
parentlibmount: remove unused mnt_strconcat3() (diff)
downloadkernel-qcow2-util-linux-9695a7c653c5e1871f7bb78fa0e6ec8d4e74a83a.tar.gz
kernel-qcow2-util-linux-9695a7c653c5e1871f7bb78fa0e6ec8d4e74a83a.tar.xz
kernel-qcow2-util-linux-9695a7c653c5e1871f7bb78fa0e6ec8d4e74a83a.zip
losetup: do not distinguish between malloc and realloc
realloc(NULL, size) behaves the same as malloc(size) so there is no need to distinguish between the two. [kzak@redhat.com: - better handle realloc() errors] Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/lomount.c')
-rw-r--r--mount/lomount.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mount/lomount.c b/mount/lomount.c
index 54b9f8e9a..03aae4b2a 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -258,11 +258,16 @@ loop_scandir(const char *dirname, int **ary, int hasprefix)
if (n == -1 || n < NLOOPS_DEFAULT)
continue;
if (count + 1 > arylen) {
+ int *tmp;
+
arylen += 1;
- *ary = *ary ? realloc(*ary, arylen * sizeof(int)) :
- malloc(arylen * sizeof(int));
- if (!*ary)
+
+ tmp = realloc(*ary, arylen * sizeof(int));
+ if (!tmp) {
+ free(*ary);
return -1;
+ }
+ *ary = tmp;
}
(*ary)[count++] = n;
}