commit 91875cfafd2591e760929b06572090be83297ab7
Author: Jan Klemkow <[email protected]>
AuthorDate: Thu Apr 16 21:07:30 2020 +0200
Commit: Jan Klemkow <[email protected]>
CommitDate: Thu Apr 16 21:07:30 2020 +0200
remove redundant code, replace eamalloc with eareallow
diff --git a/scroll.c b/scroll.c
index a87ac88..33dda40 100644
--- a/scroll.c
+++ b/scroll.c
@@ -122,26 +122,6 @@ reset(void)
die("tcsetattr:");
}
-/* error avoiding malloc */
-void *
-eamalloc(size_t size)
-{
- void *mem;
-
- while ((mem = malloc(size)) == NULL) {
- struct line *line = TAILQ_LAST(&head, tailhead);
-
- if (line == NULL)
- die("malloc:");
-
- TAILQ_REMOVE(&head, line, entries);
- free(line->buf);
- free(line);
- }
-
- return mem;
-}
-
/* error avoiding remalloc */
void *
earealloc(void *ptr, size_t size)
@@ -270,11 +250,11 @@ getcursorposition(int *x, int *y)
void
addline(char *buf, size_t size)
{
- struct line *line = eamalloc(sizeof *line);
+ struct line *line = earealloc(NULL, sizeof *line);
line->size = size;
line->len = strelen(buf, size);
- line->buf = eamalloc(size);
+ line->buf = earealloc(NULL, size);
memcpy(line->buf, buf, size);
bottom = line;