misc bugs, malloc & free
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 23 Nov 1983 11:57:11 +0000 (03:57 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 23 Nov 1983 11:57:11 +0000 (03:57 -0800)
SCCS-vsn: usr.bin/window/context.c 3.2

usr/src/usr.bin/window/context.c

index 1e38191..770c037 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)context.c   3.1 83/11/22";
+static char *sccsid = "@(#)context.c   3.2 83/11/22";
 #endif
 
 #include <stdio.h>
 #include "value.h"
 #endif
 
 #include <stdio.h>
 #include "value.h"
+#include "string.h"
 #include "context.h"
 
 /*
 #include "context.h"
 
 /*
@@ -18,7 +19,7 @@ cx_alloc()
 
        if (cx.x_type != 0) {
                xp = (struct context *)
 
        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;
                if (xp == 0)
                        return -1;
                *xp = cx;
@@ -33,9 +34,11 @@ cx_alloc()
 
 cx_free()
 {
 
 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;
 }
        } else
                cx.x_type = 0;
 }