diff --git a/src/actions.c b/src/actions.c index 1c9866e9..23e8fb86 100644 --- a/src/actions.c +++ b/src/actions.c @@ -463,6 +463,7 @@ void remove_symbol(int j) my_free(672, &xctx->sym[j].poly[c][i].selected_point); } my_free(673, &xctx->sym[j].poly[c]); + xctx->sym[j].polygons[c] = 0; for(i=0;isym[j].lines[c];i++) { @@ -472,6 +473,7 @@ void remove_symbol(int j) } } my_free(675, &xctx->sym[j].line[c]); + xctx->sym[j].lines[c] = 0; for(i=0;isym[j].arcs[c];i++) { @@ -481,6 +483,7 @@ void remove_symbol(int j) } } my_free(677, &xctx->sym[j].arc[c]); + xctx->sym[j].arcs[c] = 0; for(i=0;isym[j].rects[c];i++) { @@ -490,6 +493,7 @@ void remove_symbol(int j) } } my_free(679, &xctx->sym[j].rect[c]); + xctx->sym[j].rects[c] = 0; } for(i=0;isym[j].texts;i++) { @@ -507,6 +511,7 @@ void remove_symbol(int j) } } my_free(683, &xctx->sym[j].text); + xctx->sym[j].texts = 0; save = xctx->sym[j]; for(i = j + 1; i < xctx->symbols; i++) { @@ -518,12 +523,15 @@ void remove_symbol(int j) void remove_symbols(void) { - int j; + int j; - for(j=xctx->symbols-1;j>=0;j--) { - dbg(2, "remove_symbols(): removing symbol %d\n",j); - remove_symbol(j); - } + for(j=xctx->symbols-1;j>=0;j--) { + dbg(2, "remove_symbols(): removing symbol %d\n",j); + remove_symbol(j); + } + for(j = 0; j < xctx->instances; j++) { + xctx->inst[j].ptr = -1; /* clear symbol reference on instanecs */ + } dbg(1, "remove_symbols(): done\n"); } @@ -859,7 +867,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot xctx->inst[n].instname=NULL; xctx->inst[n].lab=NULL; dbg(1, "place_symbol(): entering my_strdup: name=%s\n",name); /* 03-02-2000 */ - my_strdup(12, &xctx->inst[n].name ,name); + my_strdup2(12, &xctx->inst[n].name ,name); dbg(1, "place_symbol(): done my_strdup: name=%s\n",name); /* 03-02-2000 */ /* xctx->inst[n].x0=symbol_name ? x : xctx->mousex_snap; */ /* xctx->inst[n].y0=symbol_name ? y : xctx->mousey_snap; */ diff --git a/src/editprop.c b/src/editprop.c index eda4cb43..2281c8e2 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -990,7 +990,7 @@ void update_symbol(const char *result, int x) delete_inst_node(*ii); /* 20180208 fix crashing bug: delete node info if changing symbol */ /* if number of pins is different we must delete these data *before* */ /* changing ysmbol, otherwise *ii might end up deleting non allocated data. */ - my_strdup(82, &xctx->inst[*ii].name, rel_sym_path(symbol)); + my_strdup2(82, &xctx->inst[*ii].name, rel_sym_path(symbol)); xctx->inst[*ii].ptr=sym_number; /* update instance to point to new symbol */ } bbox(ADD, xctx->inst[*ii].x1, xctx->inst[*ii].y1, diff --git a/src/in_memory_undo.c b/src/in_memory_undo.c index 6a4eab94..bed8182e 100644 --- a/src/in_memory_undo.c +++ b/src/in_memory_undo.c @@ -259,7 +259,7 @@ void push_undo(void) my_strdup(330, &xctx->uslot[slot].iptr[i].lab, xctx->inst[i].lab); my_strdup2(191, &xctx->uslot[slot].iptr[i].instname, xctx->inst[i].instname); my_strdup(192, &xctx->uslot[slot].iptr[i].prop_ptr, xctx->inst[i].prop_ptr); - my_strdup(193, &xctx->uslot[slot].iptr[i].name, xctx->inst[i].name); + my_strdup2(193, &xctx->uslot[slot].iptr[i].name, xctx->inst[i].name); } /* texts */ for(i=0;itexts;i++) { @@ -373,7 +373,7 @@ void pop_undo(int redo, int set_modify_status) xctx->inst[i].instname=NULL; xctx->inst[i].lab=NULL; my_strdup(214, &xctx->inst[i].prop_ptr, xctx->uslot[slot].iptr[i].prop_ptr); - my_strdup(215, &xctx->inst[i].name, xctx->uslot[slot].iptr[i].name); + my_strdup2(215, &xctx->inst[i].name, xctx->uslot[slot].iptr[i].name); my_strdup2(216, &xctx->inst[i].instname, xctx->uslot[slot].iptr[i].instname); my_strdup(766, &xctx->inst[i].lab, xctx->uslot[slot].iptr[i].lab); } diff --git a/src/move.c b/src/move.c index 6329e22e..637d07cd 100644 --- a/src/move.c +++ b/src/move.c @@ -917,7 +917,7 @@ void copy_objects(int what) xctx->inst[xctx->instances].lab=NULL; xctx->inst[xctx->instances].node=NULL; xctx->inst[xctx->instances].name=NULL; - my_strdup(232, &xctx->inst[xctx->instances].name, xctx->inst[n].name); + my_strdup2(232, &xctx->inst[xctx->instances].name, xctx->inst[n].name); my_strdup(233, &xctx->inst[xctx->instances].prop_ptr, xctx->inst[n].prop_ptr); my_strdup2(234, &xctx->inst[xctx->instances].instname, get_tok_value(xctx->inst[n].prop_ptr, "name",0)); my_strdup(312, &xctx->inst[xctx->instances].lab, xctx->inst[n].lab); diff --git a/src/psprint.c b/src/psprint.c index c4ba0799..530b658e 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -634,9 +634,10 @@ static void fill_ps_colors() { char s[200]; /* overflow safe 20161122 */ unsigned int i,c; - if(debug_var>=1) { - tcleval( "puts $ps_colors"); - } + /* if(debug_var>=1) { + * tcleval( "puts $ps_colors"); + * } + */ for(i=0;isym[i].name)) { - my_strdup(325, &xctx->sym[i].name, xctx->inst[xctx->instances-1].name); + my_strdup2(325, &xctx->sym[i].name, xctx->inst[xctx->instances-1].name); xunlink(name_embedded); found=1;break; } @@ -1693,7 +1693,7 @@ int load_sym_def(const char *name, FILE *embed_fd) symbol[symbols].type = NULL; symbol[symbols].templ = NULL; symbol[symbols].name=NULL; - my_strdup(352, &symbol[symbols].name,name); + my_strdup2(352, &symbol[symbols].name,name); while(1) { if(endfile && embed_fd && level == 0) break; /* ']' line encountered --> exit */ diff --git a/src/scheduler.c b/src/scheduler.c index d98db8f5..0f474fa5 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1919,7 +1919,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg delete_inst_node(inst); /* 20180208 fix crashing bug: delete node info if changing symbol */ /* if number of pins is different we must delete these data *before* */ /* changing ysmbol, otherwise i might end up deleting non allocated data. */ - my_strdup(369, &xctx->inst[inst].name, rel_sym_path(symbol)); + my_strdup2(369, &xctx->inst[inst].name, rel_sym_path(symbol)); xctx->inst[inst].ptr=sym_number; bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2); diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 9c2c269f..ac9edc46 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -42,7 +42,7 @@ void hier_psprint(void) /* netlister driver */ ps_draw(2); /* page */ dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) ); unselect_all(); - remove_symbols(); /* 20161205 ensure all unused symbols purged before descending hierarchy */ + remove_symbols(); /* ensure all unused symbols purged before descending hierarchy */ link_symbols_to_instances(-1); /* load_schematic(1, xctx->sch[xctx->currsch], 0); */ my_strdup(1224, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]); @@ -52,9 +52,9 @@ void hier_psprint(void) /* netlister driver */ subckt_name=NULL; for(i=0;isymbols;i++) { - if( strcmp(get_tok_value(xctx->sym[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue; - if(!xctx->sym[i].type) continue; - my_strdup(1230, &abs_path, abs_sym_path(xctx->sym[i].name, "")); + /* for printing we process also symbols that have *_ignore attribute */ + if(!xctx->sym[i].type || !xctx->sym[i].name || !xctx->sym[i].name[0]) continue; /* can not descend into */ + my_strdup2(1230, &abs_path, abs_sym_path(xctx->sym[i].name, "")); if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(2, abs_path)) { /* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */ @@ -90,9 +90,6 @@ void hier_psprint(void) /* netlister driver */ draw(); } - - - void global_spice_netlist(int global) /* netlister driver */ { int first; diff --git a/src/svgdraw.c b/src/svgdraw.c index 811a956c..197bbbab 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -523,9 +523,10 @@ static void fill_svg_colors() { char s[200]; /* overflow safe 20161122 */ unsigned int i,c; - if(debug_var>=1) { - tcleval( "puts $svg_colors"); - } + /* if(debug_var>=1) { + * tcleval( "puts $svg_colors"); + * } + */ for(i=0;i