summaryrefslogtreecommitdiff
path: root/mount
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2010-08-11 23:12:07 +0200
committerKarel Zak <kzak@redhat.com>2010-08-20 13:05:21 +0200
commit9695a7c653c5e1871f7bb78fa0e6ec8d4e74a83a (patch)
treed8a53c582ef57ca81093f9ba13a411b960dac828 /mount
parentec25979447b09387c8152d570581d963df91261e (diff)
downloadutil-linux-old-9695a7c653c5e1871f7bb78fa0e6ec8d4e74a83a.tar.gz
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')
-rw-r--r--mount/lomount.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mount/lomount.c b/mount/lomount.c
index 54b9f8e9..03aae4b2 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;
}