remove_symbols() and remove_symbol(): some symbol fields were not correctly cleared when removing all symbols. Ensure inst[].name and sym[].name are not strdup`ed as NULLs
This commit is contained in:
parent
4c17e2251e
commit
14e94eb615
|
|
@ -463,6 +463,7 @@ void remove_symbol(int j)
|
||||||
my_free(672, &xctx->sym[j].poly[c][i].selected_point);
|
my_free(672, &xctx->sym[j].poly[c][i].selected_point);
|
||||||
}
|
}
|
||||||
my_free(673, &xctx->sym[j].poly[c]);
|
my_free(673, &xctx->sym[j].poly[c]);
|
||||||
|
xctx->sym[j].polygons[c] = 0;
|
||||||
|
|
||||||
for(i=0;i<xctx->sym[j].lines[c];i++)
|
for(i=0;i<xctx->sym[j].lines[c];i++)
|
||||||
{
|
{
|
||||||
|
|
@ -472,6 +473,7 @@ void remove_symbol(int j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my_free(675, &xctx->sym[j].line[c]);
|
my_free(675, &xctx->sym[j].line[c]);
|
||||||
|
xctx->sym[j].lines[c] = 0;
|
||||||
|
|
||||||
for(i=0;i<xctx->sym[j].arcs[c];i++)
|
for(i=0;i<xctx->sym[j].arcs[c];i++)
|
||||||
{
|
{
|
||||||
|
|
@ -481,6 +483,7 @@ void remove_symbol(int j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my_free(677, &xctx->sym[j].arc[c]);
|
my_free(677, &xctx->sym[j].arc[c]);
|
||||||
|
xctx->sym[j].arcs[c] = 0;
|
||||||
|
|
||||||
for(i=0;i<xctx->sym[j].rects[c];i++)
|
for(i=0;i<xctx->sym[j].rects[c];i++)
|
||||||
{
|
{
|
||||||
|
|
@ -490,6 +493,7 @@ void remove_symbol(int j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my_free(679, &xctx->sym[j].rect[c]);
|
my_free(679, &xctx->sym[j].rect[c]);
|
||||||
|
xctx->sym[j].rects[c] = 0;
|
||||||
}
|
}
|
||||||
for(i=0;i<xctx->sym[j].texts;i++)
|
for(i=0;i<xctx->sym[j].texts;i++)
|
||||||
{
|
{
|
||||||
|
|
@ -507,6 +511,7 @@ void remove_symbol(int j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my_free(683, &xctx->sym[j].text);
|
my_free(683, &xctx->sym[j].text);
|
||||||
|
xctx->sym[j].texts = 0;
|
||||||
|
|
||||||
save = xctx->sym[j];
|
save = xctx->sym[j];
|
||||||
for(i = j + 1; i < xctx->symbols; i++) {
|
for(i = j + 1; i < xctx->symbols; i++) {
|
||||||
|
|
@ -518,12 +523,15 @@ void remove_symbol(int j)
|
||||||
|
|
||||||
void remove_symbols(void)
|
void remove_symbols(void)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for(j=xctx->symbols-1;j>=0;j--) {
|
for(j=xctx->symbols-1;j>=0;j--) {
|
||||||
dbg(2, "remove_symbols(): removing symbol %d\n",j);
|
dbg(2, "remove_symbols(): removing symbol %d\n",j);
|
||||||
remove_symbol(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");
|
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].instname=NULL;
|
||||||
xctx->inst[n].lab=NULL;
|
xctx->inst[n].lab=NULL;
|
||||||
dbg(1, "place_symbol(): entering my_strdup: name=%s\n",name); /* 03-02-2000 */
|
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 */
|
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].x0=symbol_name ? x : xctx->mousex_snap; */
|
||||||
/* xctx->inst[n].y0=symbol_name ? y : xctx->mousey_snap; */
|
/* xctx->inst[n].y0=symbol_name ? y : xctx->mousey_snap; */
|
||||||
|
|
|
||||||
|
|
@ -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 */
|
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* */
|
/* if number of pins is different we must delete these data *before* */
|
||||||
/* changing ysmbol, otherwise *ii might end up deleting non allocated data. */
|
/* 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 */
|
xctx->inst[*ii].ptr=sym_number; /* update instance to point to new symbol */
|
||||||
}
|
}
|
||||||
bbox(ADD, xctx->inst[*ii].x1, xctx->inst[*ii].y1,
|
bbox(ADD, xctx->inst[*ii].x1, xctx->inst[*ii].y1,
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ void push_undo(void)
|
||||||
my_strdup(330, &xctx->uslot[slot].iptr[i].lab, xctx->inst[i].lab);
|
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_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(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 */
|
/* texts */
|
||||||
for(i=0;i<xctx->texts;i++) {
|
for(i=0;i<xctx->texts;i++) {
|
||||||
|
|
@ -373,7 +373,7 @@ void pop_undo(int redo, int set_modify_status)
|
||||||
xctx->inst[i].instname=NULL;
|
xctx->inst[i].instname=NULL;
|
||||||
xctx->inst[i].lab=NULL;
|
xctx->inst[i].lab=NULL;
|
||||||
my_strdup(214, &xctx->inst[i].prop_ptr, xctx->uslot[slot].iptr[i].prop_ptr);
|
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_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);
|
my_strdup(766, &xctx->inst[i].lab, xctx->uslot[slot].iptr[i].lab);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -917,7 +917,7 @@ void copy_objects(int what)
|
||||||
xctx->inst[xctx->instances].lab=NULL;
|
xctx->inst[xctx->instances].lab=NULL;
|
||||||
xctx->inst[xctx->instances].node=NULL;
|
xctx->inst[xctx->instances].node=NULL;
|
||||||
xctx->inst[xctx->instances].name=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_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_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);
|
my_strdup(312, &xctx->inst[xctx->instances].lab, xctx->inst[n].lab);
|
||||||
|
|
|
||||||
|
|
@ -634,9 +634,10 @@ static void fill_ps_colors()
|
||||||
{
|
{
|
||||||
char s[200]; /* overflow safe 20161122 */
|
char s[200]; /* overflow safe 20161122 */
|
||||||
unsigned int i,c;
|
unsigned int i,c;
|
||||||
if(debug_var>=1) {
|
/* if(debug_var>=1) {
|
||||||
tcleval( "puts $ps_colors");
|
* tcleval( "puts $ps_colors");
|
||||||
}
|
* }
|
||||||
|
*/
|
||||||
for(i=0;i<cadlayers;i++) {
|
for(i=0;i<cadlayers;i++) {
|
||||||
my_snprintf(s, S(s), "lindex $ps_colors %d", i);
|
my_snprintf(s, S(s), "lindex $ps_colors %d", i);
|
||||||
tcleval( s);
|
tcleval( s);
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ void save_inst(FILE *fd, int select_only)
|
||||||
if (select_only && ptr[i].sel != SELECTED) continue;
|
if (select_only && ptr[i].sel != SELECTED) continue;
|
||||||
fputs("C ", fd);
|
fputs("C ", fd);
|
||||||
if(oldversion) {
|
if(oldversion) {
|
||||||
my_strdup(57, &tmp, add_ext(ptr[i].name, ".sym"));
|
my_strdup2(57, &tmp, add_ext(ptr[i].name, ".sym"));
|
||||||
save_ascii_string(tmp, fd, 0);
|
save_ascii_string(tmp, fd, 0);
|
||||||
my_free(882, &tmp);
|
my_free(882, &tmp);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -829,7 +829,7 @@ void read_xschem_file(FILE *fd)
|
||||||
}
|
}
|
||||||
/* if loading file coming back from embedded symbol delete temporary file */
|
/* if loading file coming back from embedded symbol delete temporary file */
|
||||||
if(!strcmp(name_embedded, xctx->sym[i].name)) {
|
if(!strcmp(name_embedded, xctx->sym[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);
|
xunlink(name_embedded);
|
||||||
found=1;break;
|
found=1;break;
|
||||||
}
|
}
|
||||||
|
|
@ -1693,7 +1693,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
||||||
symbol[symbols].type = NULL;
|
symbol[symbols].type = NULL;
|
||||||
symbol[symbols].templ = NULL;
|
symbol[symbols].templ = NULL;
|
||||||
symbol[symbols].name=NULL;
|
symbol[symbols].name=NULL;
|
||||||
my_strdup(352, &symbol[symbols].name,name);
|
my_strdup2(352, &symbol[symbols].name,name);
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(endfile && embed_fd && level == 0) break; /* ']' line encountered --> exit */
|
if(endfile && embed_fd && level == 0) break; /* ']' line encountered --> exit */
|
||||||
|
|
|
||||||
|
|
@ -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 */
|
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* */
|
/* if number of pins is different we must delete these data *before* */
|
||||||
/* changing ysmbol, otherwise i might end up deleting non allocated data. */
|
/* 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;
|
xctx->inst[inst].ptr=sym_number;
|
||||||
bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
|
bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ void hier_psprint(void) /* netlister driver */
|
||||||
ps_draw(2); /* page */
|
ps_draw(2); /* page */
|
||||||
dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) );
|
dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) );
|
||||||
unselect_all();
|
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);
|
link_symbols_to_instances(-1);
|
||||||
/* load_schematic(1, xctx->sch[xctx->currsch], 0); */
|
/* load_schematic(1, xctx->sch[xctx->currsch], 0); */
|
||||||
my_strdup(1224, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]);
|
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;
|
subckt_name=NULL;
|
||||||
for(i=0;i<xctx->symbols;i++)
|
for(i=0;i<xctx->symbols;i++)
|
||||||
{
|
{
|
||||||
if( strcmp(get_tok_value(xctx->sym[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue;
|
/* for printing we process also symbols that have *_ignore attribute */
|
||||||
if(!xctx->sym[i].type) continue;
|
if(!xctx->sym[i].type || !xctx->sym[i].name || !xctx->sym[i].name[0]) continue; /* can not descend into */
|
||||||
my_strdup(1230, &abs_path, abs_sym_path(xctx->sym[i].name, ""));
|
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))
|
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 */
|
/* 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();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void global_spice_netlist(int global) /* netlister driver */
|
void global_spice_netlist(int global) /* netlister driver */
|
||||||
{
|
{
|
||||||
int first;
|
int first;
|
||||||
|
|
|
||||||
|
|
@ -523,9 +523,10 @@ static void fill_svg_colors()
|
||||||
{
|
{
|
||||||
char s[200]; /* overflow safe 20161122 */
|
char s[200]; /* overflow safe 20161122 */
|
||||||
unsigned int i,c;
|
unsigned int i,c;
|
||||||
if(debug_var>=1) {
|
/* if(debug_var>=1) {
|
||||||
tcleval( "puts $svg_colors");
|
* tcleval( "puts $svg_colors");
|
||||||
}
|
* }
|
||||||
|
*/
|
||||||
for(i=0;i<cadlayers;i++) {
|
for(i=0;i<cadlayers;i++) {
|
||||||
if(color_ps) {
|
if(color_ps) {
|
||||||
my_snprintf(s, S(s), "lindex $svg_colors %d", i);
|
my_snprintf(s, S(s), "lindex $svg_colors %d", i);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue