aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/chars.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-30 18:43:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-30 18:43:24 +0000
commit6743cd2838c98a6c8127771ac05c6695131f26f5 (patch)
tree71c87689d03cfa48404a4ef86049447f58ae39aa /chars.c
parent8caff3a42d43b9b1377f3802a105817dcd4301dc (diff)
downloadmandoc-6743cd2838c98a6c8127771ac05c6695131f26f5.tar.gz
mandoc-6743cd2838c98a6c8127771ac05c6695131f26f5.tar.zst
mandoc-6743cd2838c98a6c8127771ac05c6695131f26f5.zip
Continued safe handling of allocations.
Diffstat (limited to 'chars.c')
-rw-r--r--chars.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/chars.c b/chars.c
index 4db245cb..34b1e9cd 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.9 2009/09/23 11:02:21 kristaps Exp $ */
+/* $Id: chars.c,v 1.10 2009/10/30 18:43:24 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);
}