summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorDavidlohr Bueso2010-10-22 17:22:56 +0200
committerKarel Zak2010-11-01 14:31:32 +0100
commit0d4e5f8e0d64b358ec2e309d9780e7854a0505ad (patch)
tree1cda0aab37ff94d86034ea2d7a07b2ba110382d1 /text-utils/more.c
parentpg: use xalloc for memory allocation (diff)
downloadkernel-qcow2-util-linux-0d4e5f8e0d64b358ec2e309d9780e7854a0505ad.tar.gz
kernel-qcow2-util-linux-0d4e5f8e0d64b358ec2e309d9780e7854a0505ad.tar.xz
kernel-qcow2-util-linux-0d4e5f8e0d64b358ec2e309d9780e7854a0505ad.zip
more: use xalloc for memory allocation
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index 20efc28d6..375205984 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -36,6 +36,8 @@
libcurses (and hence can be in /bin with libcurses being in /usr/lib
which may not be mounted). However, when termcap is not present curses
can still be used.
+ 2010-10-21 Davidlohr Bueso <dave@gnu.org>
+ - modified mem allocation handling for util-linux-ng
*/
#include <stdio.h>
@@ -55,7 +57,9 @@
#include <sys/file.h>
#include <sys/wait.h>
#include "xstrncpy.h"
+
#include "nls.h"
+#include "xalloc.h"
#include "widechar.h"
#define _REGEX_RE_COMP
@@ -2015,22 +2019,14 @@ int expand (char **outbuf, char *inbuf) {
xtra = strlen (fnames[fnum]) + strlen (shell_line) + 1;
tempsz = 200 + xtra;
- temp = malloc(tempsz);
- if (!temp) {
- error (_("Out of memory"));
- return -1;
- }
+ temp = xmalloc(tempsz);
inpstr = inbuf;
outstr = temp;
while ((c = *inpstr++) != '\0'){
offset = outstr-temp;
if (tempsz-offset-1 < xtra) {
tempsz += 200 + xtra;
- temp = realloc(temp, tempsz);
- if (!temp) {
- error (_("Out of memory"));
- return -1;
- }
+ temp = xrealloc(temp, tempsz);
outstr = temp + offset;
}
switch (c) {