summaryrefslogtreecommitdiff
path: root/usr.bin/tic
diff options
context:
space:
mode:
authorjoerg <joerg@NetBSD.org>2012-05-31 20:38:19 +0000
committerjoerg <joerg@NetBSD.org>2012-05-31 20:38:19 +0000
commit635369e8b6c7809ddb0c726a584ae3a080bb1b69 (patch)
tree62855d9ca7f4d16d8f4bdc318fa35543c26b94b5 /usr.bin/tic
parentc2370ad4e5a1249000824ab10e45e2fba769192d (diff)
Use e* from util.h.
Diffstat (limited to 'usr.bin/tic')
-rw-r--r--usr.bin/tic/tic.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c
index 4bed7549e75..c78c4f57f5c 100644
--- a/usr.bin/tic/tic.c
+++ b/usr.bin/tic/tic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.15 2012/05/31 20:10:06 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.16 2012/05/31 20:38:19 joerg Exp $ */
/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tic.c,v 1.15 2012/05/31 20:10:06 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.16 2012/05/31 20:38:19 joerg Exp $");
#include <sys/types.h>
#include <sys/queue.h>
@@ -142,13 +142,9 @@ store_term(const char *name, char type)
TERM *term;
ENTRY elem;
- term = calloc(1, sizeof(*term));
- if (term == NULL)
- errx(1, "malloc");
- term->name = strdup(name);
+ term = ecalloc(1, sizeof(*term));
+ term->name = estrdup(name);
term->type = type;
- if (term->name == NULL)
- errx(1, "malloc");
SLIST_INSERT_HEAD(&terms, term, next);
elem.key = estrdup(name);
elem.data = term;
@@ -197,12 +193,8 @@ process_entry(TBUF *buf, int flags)
" term %s", tic->name, p);
} else {
term = store_term(p, 'a');
- term->tic = calloc(sizeof(*term->tic), 1);
- if (term->tic == NULL)
- err(1, "malloc");
- term->tic->name = strdup(tic->name);
- if (term->tic->name == NULL)
- err(1, "malloc");
+ term->tic = ecalloc(sizeof(*term->tic), 1);
+ term->tic->name = estrdup(tic->name);
}
p = e;
}
@@ -499,9 +491,7 @@ main(int argc, char **argv)
if (ofile == NULL)
ofile = source;
len = strlen(ofile) + 9;
- dbname = malloc(len + 4); /* For adding .db after open */
- if (dbname == NULL)
- err(1, "malloc");
+ dbname = emalloc(len + 4); /* For adding .db after open */
snprintf(dbname, len, "%s.tmp", ofile);
db = dbm_open(dbname, O_CREAT | O_RDWR | O_TRUNC, DEFFILEMODE);
if (db == NULL)
@@ -571,11 +561,7 @@ main(int argc, char **argv)
dbm_close(db);
/* Rename the tmp db to the real one now */
- len = strlen(ofile) + 4;
- p = malloc(len);
- if (p == NULL)
- err(1, "malloc");
- snprintf(p, len, "%s.db", ofile);
+ easprintf(&p, "%s.db", ofile);
if (rename(dbname, p) == -1)
err(1, "rename");
free(dbname);
@@ -584,6 +570,7 @@ main(int argc, char **argv)
if (sflag != 0)
fprintf(stderr, "%zu entries and %zu aliases written to %s\n",
nterm, nalias, p);
+ free(p);
hdestroy();
span title='2001-03-22 07:37:04 +0000'>2001-03-22Sprinkle some restrict qualifiers.kleink 2000-01-10Move <null.h> to <sys/null.h> for the purpose of avoiding conflicts due tokleink 1999-12-22For the benefit of G++'s null pointer constant implementation, #define NULLkleink 1999-09-09strlcat() and strlcpy() aren't ISO/IEC 9899:1990.kleink 1999-09-08prototypes for strlcat() and strlcpy()lukem 1998-07-27Make many of the new consts dependent on a new `__AUDIT__' flag, to avoidmycroft 1998-07-26KNF nit.mycroft 1998-07-26const poisoning.mycroft