Author: leo
Date: Fri Nov 4 06:10:03 2005
New Revision: 9772
Modified:
trunk/imcc/imc.c
trunk/imcc/main.c
trunk/src/dod.c
trunk/src/register.c
Log:
[perl #37605] [PATCH] fix a warning in main.c
This patch fixes a warning in main.c by removing an unnecessary strdup
and following free.
Courtesy of Matt Fowles <[EMAIL PROTECTED]>
Modified: trunk/imcc/imc.c
==============================================================================
--- trunk/imcc/imc.c (original)
+++ trunk/imcc/imc.c Fri Nov 4 06:10:03 2005
@@ -144,11 +144,6 @@ imc_close_unit(Parrot_Interp interp, IMC
cur_unit = NULL;
}
-/*
- * XXX FIXME: Memory leakage. Can't call free_reglist or clear_tables()
- * yet due to interaction between units. One unit may hold a reference
- * to another (subs). Garbage collection would solve this.
- */
static void
imc_free_unit(Parrot_Interp interp, IMC_Unit * unit)
{
@@ -158,9 +153,7 @@ imc_free_unit(Parrot_Interp interp, IMC_
fprintf(stderr, "imc_free_unit()\n");
#endif
- /* XXX See above
free_reglist(unit);
- */
clear_basic_blocks(unit); /* and cfg ... */
if (!imc->n_comp_units)
Modified: trunk/imcc/main.c
==============================================================================
--- trunk/imcc/main.c (original)
+++ trunk/imcc/main.c Fri Nov 4 06:10:03 2005
@@ -292,14 +292,14 @@ parseflags(Parrot_Interp interp, int *ar
break;
case 'o':
run_pbc = 0;
- interp->output_file = str_dup(opt.opt_arg);
+ interp->output_file = opt.opt_arg;
break;
case OPT_PBC_OUTPUT:
run_pbc = 0;
write_pbc = 1;
if (!interp->output_file)
- interp->output_file = str_dup("-");
+ interp->output_file = "-";
break;
case 'O':
@@ -453,7 +453,7 @@ main(int argc, char * argv[])
struct PackFile *pf;
int obj_file, ast_file = 0;
char *sourcefile;
- char *output_file;
+ const char *output_file;
Interp *interp = Parrot_new(NULL);
@@ -645,8 +645,6 @@ main(int argc, char * argv[])
/* Clean-up after ourselves */
Parrot_destroy(interp);
- if (output_file)
- free(output_file);
mem_sys_free(IMCC_INFO(interp));
Parrot_exit(0);
Modified: trunk/src/dod.c
==============================================================================
--- trunk/src/dod.c (original)
+++ trunk/src/dod.c Fri Nov 4 06:10:03 2005
@@ -519,8 +519,6 @@ trace_active_buffers(Interp *interpreter
/* The interpreter might have a few strings of its own,
* but currently there are none.
* When the interpreter gets strings again, then mark them as alive */
- /* if (interpreter->output_file)
- pobject_lives(interpreter, (PObj *)interpreter->output_file) */;
}
#ifdef GC_IS_MALLOC
Modified: trunk/src/register.c
==============================================================================
--- trunk/src/register.c (original)
+++ trunk/src/register.c Fri Nov 4 06:10:03 2005
@@ -138,6 +138,17 @@ create_initial_context(Interp *interpret
void
destroy_context(Interp *interpreter)
{
+ int slot;
+ void *ptr, *next;
+
+ for (slot = 0; slot < interpreter->ctx_mem.n_free_slots; ++slot) {
+ ptr = interpreter->ctx_mem.free_list[slot];
+ while (ptr) {
+ next = *(void **) ptr;
+ mem_sys_free(ptr);
+ ptr = next;
+ }
+ }
mem_sys_free(interpreter->ctx_mem.free_list);
}