I ran p2c under valgrind with Zdenek's code, which revealed two memory
management errors: a double free in decl.c and freeing of memory still
in use in parse.c. The attached patch just comments out the offending
free's.
diff -ur p2c-1.21alpha2/src/decl.c p2c-pdw/src/decl.c
--- p2c-1.21alpha2/src/decl.c   1993-12-08 06:36:50.000000000 +0100
+++ p2c-pdw/src/decl.c  2005-04-26 01:16:16.000000000 +0200
@@ -789,8 +789,10 @@
                mpp2 = &mp2->snext;
            if (mp2)
                *mpp2 = mp2->snext;
+#if 0
            if (mp->kind == MK_CONST)
                free_value(&mp->val);
+#endif
            freeexpr(mp->constdefn);
            if (mp->cbase)
                forget_ctx(mp, 1);
diff -ur p2c-1.21alpha2/src/parse.c p2c-pdw/src/parse.c
--- p2c-1.21alpha2/src/parse.c  1993-12-08 06:36:49.000000000 +0100
+++ p2c-pdw/src/parse.c 2005-04-26 01:16:33.000000000 +0200
@@ -4642,8 +4642,10 @@
        }
     }
     if (conserve_mem) {
+#if 0
        free_stmt((Stmt *)func->val.i);   /* is this safe? */
        func->val.i = 0;
+#endif
        forget_ctx(func, 0);
     }
     outsection(spacing);

Reply via email to