Introduction
Introduction Statistics Contact Development Disclaimer Help
remove redundant code, replace eamalloc with eareallow - scroll - scrollbackbuf…
git clone git://git.suckless.org/scroll
Log
Files
Refs
README
LICENSE
---
commit 91875cfafd2591e760929b06572090be83297ab7
parent 5497edaec0dbb2b49ba643e834c0de336b56a603
Author: Jan Klemkow <[email protected]>
Date: Thu, 16 Apr 2020 21:07:30 +0200
remove redundant code, replace eamalloc with eareallow
Diffstat:
M scroll.c | 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)
---
diff --git 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;
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.