cvsuser 03/01/17 12:41:02
Modified: include/parrot oplib.h
. interpreter.c ops2c.pl
Log:
fixed mem leak in op_info
Revision Changes Path
1.8 +4 -3 parrot/include/parrot/oplib.h
Index: oplib.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/oplib.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- oplib.h 9 Oct 2002 03:56:11 -0000 1.7
+++ oplib.h 17 Jan 2003 20:40:57 -0000 1.8
@@ -1,7 +1,7 @@
/* oplib.h
* Copyright: (When this is determined...it will go here)
* CVS Info
- * $Id: oplib.h,v 1.7 2002/10/09 03:56:11 sfink Exp $
+ * $Id: oplib.h,v 1.8 2003/01/17 20:40:57 leo Exp $
* Overview:
* Header file for op libraries.
* Data Structure and Algorithms:
@@ -32,7 +32,8 @@
int (*op_code)(const char * name, int full);
} op_lib_t;
-typedef op_lib_t *(*oplib_init_f)(void);
+/* when init = true initialize, else de_initialize */
+typedef op_lib_t *(*oplib_init_f)(int init);
#endif
1.130 +10 -6 parrot/interpreter.c
Index: interpreter.c
===================================================================
RCS file: /cvs/public/parrot/interpreter.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -w -r1.129 -r1.130
--- interpreter.c 17 Jan 2003 15:10:46 -0000 1.129
+++ interpreter.c 17 Jan 2003 20:41:01 -0000 1.130
@@ -1,7 +1,7 @@
/* interpreter.c
* Copyright: (When this is determined...it will go here)
* CVS Info
- * $Id: interpreter.c,v 1.129 2003/01/17 15:10:46 leo Exp $
+ * $Id: interpreter.c,v 1.130 2003/01/17 20:41:01 leo Exp $
* Overview:
* The interpreter api handles running the operations
* Data Structure and Algorithms:
@@ -14,6 +14,7 @@
#include "parrot/parrot.h"
#include "parrot/interp_guts.h"
#include "parrot/oplib/core_ops.h"
+#include "parrot/oplib/core_ops_prederef.h"
#include "parrot/runops_cores.h"
#ifdef HAS_JIT
# include "parrot/jit.h"
@@ -25,7 +26,6 @@
#define ATEXIT_DESTROY
-extern op_lib_t *PARROT_CORE_PREDEREF_OPLIB_INIT(void);
static void setup_default_compreg(Parrot_Interp interpreter);
@@ -78,7 +78,7 @@
if (!init_func)
internal_exception(1, "Invalid oplib, '%s' not exported\n",
init_func_name);
- oplib = init_func();
+ oplib = init_func(1);
/* XXX now what
* if oplib is a prederefed oplib, and matches the current
* oplib, we would run it */
@@ -200,7 +200,7 @@
static void
init_prederef(struct Parrot_Interp *interpreter)
{
- interpreter->op_lib = PARROT_CORE_PREDEREF_OPLIB_INIT();
+ interpreter->op_lib = PARROT_CORE_PREDEREF_OPLIB_INIT(1);
if (interpreter->op_lib->op_count != interpreter->op_count)
internal_exception(PREDEREF_LOAD_ERROR,
"Illegal op count (%d) in prederef oplib\n",
@@ -226,7 +226,8 @@
static void
stop_prederef(struct Parrot_Interp *interpreter)
{
- interpreter->op_lib = PARROT_CORE_OPLIB_INIT();
+ (void) PARROT_CORE_PREDEREF_OPLIB_INIT(0);
+ interpreter->op_lib = PARROT_CORE_OPLIB_INIT(1);
}
static void
@@ -485,7 +486,7 @@
interpreter->ctx.intstack = intstack_new(interpreter);
/* Load the core op func and info tables */
- interpreter->op_lib = PARROT_CORE_OPLIB_INIT();
+ interpreter->op_lib = PARROT_CORE_OPLIB_INIT(1);
interpreter->op_count = interpreter->op_lib->op_count;
interpreter->op_func_table = interpreter->op_lib->op_func_table;
interpreter->op_info_table = interpreter->op_lib->op_info_table;
@@ -559,6 +560,9 @@
free(interpreter->prederef_code);
mem_sys_free(interpreter->warns);
+
+ /* deinit op_lib */
+ interpreter->op_lib = PARROT_CORE_OPLIB_INIT(0);
/* XXX move this to register.c */
{
1.36 +16 -9 parrot/ops2c.pl
Index: ops2c.pl
===================================================================
RCS file: /cvs/public/parrot/ops2c.pl,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -w -r1.35 -r1.36
--- ops2c.pl 17 Jan 2003 07:36:41 -0000 1.35
+++ ops2c.pl 17 Jan 2003 20:41:01 -0000 1.36
@@ -5,7 +5,7 @@
# Generate a C header and source file from the operation definitions in
# an .ops file, using a supplied transform.
#
-# $Id: ops2c.pl,v 1.35 2003/01/17 07:36:41 leo Exp $
+# $Id: ops2c.pl,v 1.36 2003/01/17 20:41:01 leo Exp $
#
use strict;
@@ -128,7 +128,7 @@
#include "parrot/parrot.h"
#include "parrot/oplib.h"
-extern op_lib_t *
Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(void);
+extern op_lib_t
*Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(int
init);
END_C
@@ -374,6 +374,7 @@
{
HOP *p, *next;
size_t i;
+ if (hop)
for (i = 0; i < OP_HASH_SIZE; i++)
for(p = hop[i]; p; ) {
next = p->next;
@@ -404,8 +405,14 @@
get_op
};
-op_lib_t *
Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(void)
{
+op_lib_t *
+Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(int
init) {
+ if (init)
return &op_lib;
+ else {
+ hop_deinit();
+ return NULL;
+ }
}
END_C