From eb6f9f1f4ed9958bafa70b725e4899fea481ef00 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 21 Nov 2023 10:48:56 +0100 Subject: [PATCH] fix a small memory leak in spice_netlist.c --- src/scheduler.c | 16 ++++++++++++---- src/spice_netlist.c | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 17aafc18..95f7f6e8 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -4804,19 +4804,27 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg draw(); del_object_table(); + Tcl_ResetResult(interp); } else if(argc > 2 && atoi(argv[2]) == 2) { copy_hierarchy_data(".drw", ".x1.drw"); + Tcl_ResetResult(interp); } else if(argc > 2 && atoi(argv[2]) == 3) { Xschem_ctx **save_xctx = get_save_xctx(); save_xctx[1]->raw = save_xctx[0]->raw; + Tcl_ResetResult(interp); } - else if(argc > 4 && atoi(argv[2]) == 4) { - raw_read(argv[3], &xctx->raw, argv[4]); - xctx->raw->level = 0; + else if(argc > 2 && atoi(argv[2]) == 4) { + Xschem_ctx **save_xctx = get_save_xctx(); + save_xctx[1]->raw = NULL; + Tcl_ResetResult(interp); + } + else if(argc > 2 && atoi(argv[2]) == 5) { + Xschem_ctx **save_xctx = get_save_xctx(); + Tcl_SetResult(interp, save_xctx[1]->raw == NULL ? "null" : "not null", TCL_VOLATILE); + } - Tcl_ResetResult(interp); } /* text x y rot flip text props size draw diff --git a/src/spice_netlist.c b/src/spice_netlist.c index c991bc11..417d2667 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -326,8 +326,8 @@ int global_spice_netlist(int global) /* netlister driver */ found_top_symbol = 1; } remove_symbol(xctx->symbols - 1); - my_free(_ALLOC_ID_, &top_symbol_name); } + my_free(_ALLOC_ID_, &top_symbol_name); if(!found_top_symbol) { for(i=0;iinstances; ++i) { if(skip_instance(i, 1, lvs_ignore)) continue;