From 98c262159b865188be0a3728dfc065cc3e83da7f Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Wed, 23 Nov 1983 03:57:11 -0800 Subject: [PATCH] misc bugs, malloc & free SCCS-vsn: usr.bin/window/context.c 3.2 --- usr/src/usr.bin/window/context.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/usr/src/usr.bin/window/context.c b/usr/src/usr.bin/window/context.c index 1e38191234..770c037722 100644 --- a/usr/src/usr.bin/window/context.c +++ b/usr/src/usr.bin/window/context.c @@ -1,9 +1,10 @@ #ifndef lint -static char *sccsid = "@(#)context.c 3.1 83/11/22"; +static char *sccsid = "@(#)context.c 3.2 83/11/22"; #endif #include #include "value.h" +#include "string.h" #include "context.h" /* @@ -18,7 +19,7 @@ cx_alloc() if (cx.x_type != 0) { xp = (struct context *) - malloc(1, (unsigned) sizeof (struct context)); + malloc((unsigned) sizeof (struct context)); if (xp == 0) return -1; *xp = cx; @@ -33,9 +34,11 @@ cx_alloc() cx_free() { - if (cx.x_link != 0) { - free(cx.x_link); - cx = *cx.x_link; + struct context *xp; + + if ((xp = cx.x_link) != 0) { + cx = *xp; + free((char *)xp); } else cx.x_type = 0; } -- 2.20.1