summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chars.c17
-rw-r--r--html.c20
-rw-r--r--term.c7
3 files changed, 27 insertions, 17 deletions
diff --git a/chars.c b/chars.c
index a528de2d..fc43b26b 100644
--- a/chars.c
+++ b/chars.c
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <assert.h>
-#include <err.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -89,13 +89,17 @@ chars_init(enum chars type)
* (they're in-line re-ordered during lookup).
*/
- if (NULL == (tab = malloc(sizeof(struct tbl))))
- err(1, "malloc");
- tab->type = type;
+ tab = malloc(sizeof(struct tbl));
+ if (NULL == tab) {
+ fprintf(stderr, "memory exhausted\n");
+ exit(EXIT_FAILURE);
+ }
htab = calloc(PRINT_HI - PRINT_LO + 1, sizeof(struct ln **));
- if (NULL == htab)
- err(1, "malloc");
+ if (NULL == htab) {
+ fprintf(stderr, "memory exhausted\n");
+ exit(EXIT_FAILURE);
+ }
for (i = 0; i < LINES_MAX; i++) {
hash = (int)lines[i].code[0] - PRINT_LO;
@@ -111,6 +115,7 @@ chars_init(enum chars type)
}
tab->htab = htab;
+ tab->type = type;
return(tab);
}
diff --git a/html.c b/html.c
index ffa9ed33..6990841b 100644
--- a/html.c
+++ b/html.c
@@ -100,16 +100,15 @@ html_alloc(char *outopts)
toks[2] = "includes";
toks[3] = NULL;
- if (NULL == (h = calloc(1, sizeof(struct html))))
- return(NULL);
+ h = calloc(1, sizeof(struct html));
+ if (NULL == h) {
+ fprintf(stderr, "memory exhausted\n");
+ exit(EXIT_FAILURE);
+ }
h->tags.head = NULL;
h->ords.head = NULL;
-
- if (NULL == (h->symtab = chars_init(CHARS_HTML))) {
- free(h);
- return(NULL);
- }
+ h->symtab = chars_init(CHARS_HTML);
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
@@ -354,8 +353,11 @@ print_otag(struct html *h, enum htmltag tag,
struct tag *t;
if ( ! (HTML_NOSTACK & htmltags[tag].flags)) {
- if (NULL == (t = malloc(sizeof(struct tag))))
- err(EXIT_FAILURE, "malloc");
+ t = malloc(sizeof(struct tag));
+ if (NULL == t) {
+ fprintf(stderr, "memory exhausted\n");
+ exit(EXIT_FAILURE);
+ }
t->tag = tag;
t->next = h->tags.head;
h->tags.head = t;
diff --git a/term.c b/term.c
index 3fdb4cc1..15ab98ef 100644
--- a/term.c
+++ b/term.c
@@ -77,8 +77,11 @@ term_alloc(enum termenc enc)
{
struct termp *p;
- if (NULL == (p = calloc(1, sizeof(struct termp))))
- return(NULL);
+ p = calloc(1, sizeof(struct termp));
+ if (NULL == p) {
+ fprintf(stderr, "memory exhausted\n");
+ exit(EXIT_FAILURE);
+ }
p->maxrmargin = 78;
p->enc = enc;
return(p);