scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit ef6ebfdd2c77c82be5ed3e50e13031d05598f905
parent 2906c0ed1636c2d72485027f3fa9cb56fe54ba1b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  4 Jul 2013 18:54:29 +0200

Fix bug allocating ctype struct

The sizeof was incorrect because we were reserving space for the
pointer, and we should reserve the size for the content.

Diffstat:
types.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/types.c b/types.c @@ -15,9 +15,9 @@ static unsigned char *stackp = stack; struct ctype * newctype(void) { - register struct ctype *tp = xcalloc(sizeof(tp), 1); + register struct ctype *tp = xcalloc(sizeof(*tp), 1); - ++tp->refcnt; + tp->refcnt = 1; return tp; }