summaryrefslogtreecommitdiff
path: root/editors/ed.c
diff options
context:
space:
mode:
authorDenys Vlasenko2010-01-08 09:07:50 +0100
committerDenys Vlasenko2010-01-08 09:07:50 +0100
commit9037787eaee5efb58fd46f326397193b16b161dd (patch)
treedfd0e7d93faf711ca7dcf8c7fe0abfb21082e3d3 /editors/ed.c
parentef3817c6dcbf9270d36b48a0547e507221abce74 (diff)
downloadbusybox-9037787eaee5efb58fd46f326397193b16b161dd.zip
busybox-9037787eaee5efb58fd46f326397193b16b161dd.tar.gz
*: fix places where we were still using malloc/realloc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors/ed.c')
-rw-r--r--editors/ed.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/editors/ed.c b/editors/ed.c
index 9ce8bea..516b8d7 100644
--- a/editors/ed.c
+++ b/editors/ed.c
@@ -454,11 +454,7 @@ static void subCommand(const char *cmd, int num1, int num2)
* structure and use that. Link it in in place of
* the old line structure.
*/
- nlp = malloc(sizeof(LINE) + lp->len + deltaLen);
- if (nlp == NULL) {
- bb_error_msg("can't get memory for line");
- return;
- }
+ nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen);
nlp->len = lp->len + deltaLen;
@@ -712,12 +708,7 @@ static int readLines(const char *file, int num)
if (bufUsed >= bufSize) {
len = (bufSize * 3) / 2;
- cp = realloc(bufBase, len);
- if (cp == NULL) {
- bb_error_msg("no memory for buffer");
- close(fd);
- return FALSE;
- }
+ cp = xrealloc(bufBase, len);
bufBase = cp;
bufPtr = bufBase + bufUsed;
bufSize = len;
@@ -872,11 +863,7 @@ static int insertLine(int num, const char *data, int len)
return FALSE;
}
- newLp = malloc(sizeof(LINE) + len - 1);
- if (newLp == NULL) {
- bb_error_msg("failed to allocate memory for line");
- return FALSE;
- }
+ newLp = xmalloc(sizeof(LINE) + len - 1);
memcpy(newLp->data, data, len);
newLp->len = len;