tuse err() - sex - libtermbox based text editor
(HTM) git clone git://z3bra.org/sex
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit aa6e1c2e0b096ce764e3d97b920de7944975b93a
(DIR) parent 9e6662fa43f6c1c6620b72a70a6e7e670beb56e8
(HTM) Author: dcat <dcat@iotek.org>
Date: Thu, 19 Nov 2015 15:28:11 +0100
use err()
Diffstat:
M sex.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/sex.c b/sex.c
t@@ -78,10 +78,9 @@ open_file(char *path)
for (i = last_eol = 0; i < f.size; ++i) {
if (*(f.map + i) == '\n') {
tmp = malloc(sizeof(*tmp));
- if (tmp == NULL) {
- perror("malloc failed");
- exit(1);
- }
+ if (tmp == NULL)
+ err(1, "malloc()");
+
tmp->p = f.map + last_eol;
tmp->len = i - last_eol + 1;
last_eol = i + 1;