summaryrefslogtreecommitdiffstats
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
commitea8cd0ee934ae86efb80393ca7b51e913e55043f (patch)
treebcb6bc3fb271ba628322b5e83d21979abc00ba5d /chars.c
parente46c16c46ad18d40f21b251bf8995387efa68796 (diff)
downloadmandoc-ea8cd0ee934ae86efb80393ca7b51e913e55043f.tar.gz
Continued safe handling of allocations.
Diffstat (limited to 'chars.c')
-rw-r--r--chars.c17
1 files changed, 11 insertions, 6 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);
}