summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2014-01-08 22:30:33 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2014-01-08 22:30:33 +0000
commit0952790e2da3a472d1c83e1d025b7c8a47edb403 (patch)
tree2058afe94fb94ba9be965c8b17f1c75480c97580 /usr.bin
parent9b833aa007e8fe8cf8bedb7aa2a35a80d77e6571 (diff)
Make allocate() take size_t and return void *. This lets us drop
some more useless casts. Also add missing arguments to a couple of prototypes while here. OK matthew@ pelikan@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/yacc/defs.h12
-rw-r--r--usr.bin/yacc/lr0.c10
-rw-r--r--usr.bin/yacc/main.c16
3 files changed, 18 insertions, 20 deletions
diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h
index 02de7b5b7b0..1aa9f3d8e02 100644
--- a/usr.bin/yacc/defs.h
+++ b/usr.bin/yacc/defs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: defs.h,v 1.13 2014/01/08 21:40:25 millert Exp $ */
+/* $OpenBSD: defs.h,v 1.14 2014/01/08 22:30:32 millert Exp $ */
/* $NetBSD: defs.h,v 1.6 1996/03/19 03:21:30 jtc Exp $ */
/*
@@ -137,8 +137,8 @@
/* storage allocation macros */
-#define NEW(t) ((t*)allocate(sizeof(t)))
-#define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t))))
+#define NEW(t) (allocate(sizeof(t)))
+#define NEW2(n,t) (allocate((n)*sizeof(t)))
/* the structure of a symbol table entry */
@@ -305,9 +305,9 @@ extern short final_state;
/* global functions */
-extern char *allocate();
-extern bucket *lookup();
-extern bucket *make_bucket();
+extern void *allocate(size_t);
+extern bucket *lookup(char *);
+extern bucket *make_bucket(char *);
extern void set_first_derives(void);
extern void closure(short *, int);
extern void finalize_closure(void);
diff --git a/usr.bin/yacc/lr0.c b/usr.bin/yacc/lr0.c
index a7632093898..10e4b2146c4 100644
--- a/usr.bin/yacc/lr0.c
+++ b/usr.bin/yacc/lr0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lr0.c,v 1.13 2014/01/08 21:40:25 millert Exp $ */
+/* $OpenBSD: lr0.c,v 1.14 2014/01/08 22:30:32 millert Exp $ */
/* $NetBSD: lr0.c,v 1.4 1996/03/19 03:21:35 jtc Exp $ */
/*
@@ -343,7 +343,7 @@ new_state(int symbol)
iend = kernel_end[symbol];
n = iend - isp1;
- p = (core *) allocate((unsigned) (sizeof(core) + (n - 1) * sizeof(short)));
+ p = allocate(sizeof(core) + (n - 1) * sizeof(short));
p->accessing_symbol = symbol;
p->number = nstates;
p->nitems = n;
@@ -369,8 +369,7 @@ save_shifts(void)
short *sp2;
short *send;
- p = (shifts *) allocate((unsigned) (sizeof(shifts) +
- (nshifts - 1) * sizeof(short)));
+ p = allocate(sizeof(shifts) + (nshifts - 1) * sizeof(short));
p->number = this_state->number;
p->nshifts = nshifts;
@@ -418,8 +417,7 @@ save_reductions(void)
if (count)
{
- p = (reductions *) allocate((unsigned) (sizeof(reductions) +
- (count - 1) * sizeof(short)));
+ p = allocate(sizeof(reductions) + (count - 1) * sizeof(short));
p->number = this_state->number;
p->nreds = count;
diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c
index 2a2384a2249..77a343d6278 100644
--- a/usr.bin/yacc/main.c
+++ b/usr.bin/yacc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.24 2014/01/08 21:40:25 millert Exp $ */
+/* $OpenBSD: main.c,v 1.25 2014/01/08 22:30:32 millert Exp $ */
/* $NetBSD: main.c,v 1.5 1996/03/19 03:21:38 jtc Exp $ */
/*
@@ -213,18 +213,18 @@ getargs(int argc, char *argv[])
}
-char *
-allocate(unsigned int n)
+void *
+allocate(size_t n)
{
- char *p;
+ void *v;
- p = NULL;
+ v = NULL;
if (n)
{
- p = calloc(1, n);
- if (!p) no_space();
+ v = calloc(1, n);
+ if (!v) no_space();
}
- return (p);
+ return (v);
}
#define TEMPNAME(s, c, d, l) \