some other static data eliminated from functions (edit symbol_property), in_memory undo structure moved into schematic context

This commit is contained in:
Stefan Frederik 2021-11-19 23:22:54 +01:00
parent 4cb0a12d64
commit 83746efbe9
6 changed files with 256 additions and 247 deletions

View File

@ -822,7 +822,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot
/* use the given params, otherwise query user */ /* use the given params, otherwise query user */
{ {
int i,j,n; int i,j,n;
static char name[PATH_MAX]; char name[PATH_MAX];
char *type; char *type;
int cond; int cond;
if(symbol_name==NULL) { if(symbol_name==NULL) {

View File

@ -23,8 +23,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "xschem.h" #include "xschem.h"
static short rot = 0, flip = 0;
char *my_strtok_r(char *str, const char *delim, char **saveptr) char *my_strtok_r(char *str, const char *delim, char **saveptr)
{ {
char *tok; char *tok;
@ -700,6 +698,7 @@ void edit_polygon_property(void)
/* x=0 use text widget x=1 use vim editor */ /* x=0 use text widget x=1 use vim editor */
void edit_text_property(int x) void edit_text_property(int x)
{ {
int rot, flip;
#if HAS_CAIRO==1 #if HAS_CAIRO==1
int customfont; int customfont;
#endif #endif
@ -861,24 +860,26 @@ void edit_text_property(int x)
void edit_symbol_property(int x) void edit_symbol_property(int x)
{ {
char *result=NULL; char *result=NULL;
int *ii = &xctx->edit_sym_i; /* static var */
int *netl_com = &xctx->netlist_commands; /* static var */
xctx->edit_sym_i=xctx->sel_array[0].n; *ii=xctx->sel_array[0].n;
xctx->netlist_commands = 0; *netl_com = 0;
if ((xctx->inst[xctx->edit_sym_i].ptr + xctx->sym)->type!=NULL) if ((xctx->inst[*ii].ptr + xctx->sym)->type!=NULL)
xctx->netlist_commands = *netl_com =
!strcmp( (xctx->inst[xctx->edit_sym_i].ptr+ xctx->sym)->type, "xctx->netlist_commands"); !strcmp( (xctx->inst[*ii].ptr+ xctx->sym)->type, "netlist_commands");
if(xctx->inst[xctx->edit_sym_i].prop_ptr!=NULL) { if(xctx->inst[*ii].prop_ptr!=NULL) {
if(xctx->netlist_commands && x==1) { if(*netl_com && x==1) {
tclsetvar("retval",get_tok_value( xctx->inst[xctx->edit_sym_i].prop_ptr,"value",0)); tclsetvar("retval",get_tok_value( xctx->inst[*ii].prop_ptr,"value",0));
} else { } else {
tclsetvar("retval",xctx->inst[xctx->edit_sym_i].prop_ptr); tclsetvar("retval",xctx->inst[*ii].prop_ptr);
} }
} }
else { else {
tclsetvar("retval",""); tclsetvar("retval","");
} }
my_strdup(91, &xctx->old_prop, xctx->inst[xctx->edit_sym_i].prop_ptr); my_strdup(91, &xctx->old_prop, xctx->inst[*ii].prop_ptr);
tclsetvar("symbol",xctx->inst[xctx->edit_sym_i].name); tclsetvar("symbol",xctx->inst[*ii].name);
if(x==0) { if(x==0) {
tcleval("edit_prop {Input property:}"); tcleval("edit_prop {Input property:}");
@ -888,7 +889,7 @@ void edit_symbol_property(int x)
/* edit_vi_netlist_prop will replace \" with " before editing, /* edit_vi_netlist_prop will replace \" with " before editing,
replace back " with \" when done and wrap the resulting text with quotes replace back " with \" when done and wrap the resulting text with quotes
("text") when done */ ("text") when done */
if(xctx->netlist_commands && x==1) tcleval("edit_vi_netlist_prop {Input property:}"); if(*netl_com && x==1) tcleval("edit_vi_netlist_prop {Input property:}");
else if(x==1) tcleval("edit_vi_prop {Input property:}"); else if(x==1) tcleval("edit_vi_prop {Input property:}");
else if(x==2) tcleval("viewdata $::retval"); else if(x==2) tcleval("viewdata $::retval");
my_strdup(78, &result, tclresult()); my_strdup(78, &result, tclresult());
@ -897,7 +898,7 @@ void edit_symbol_property(int x)
update_symbol(result, x); update_symbol(result, x);
my_free(728, &result); my_free(728, &result);
dbg(1, "edit_symbol_property(): done update_symbol, modified=%d\n", xctx->modified); dbg(1, "edit_symbol_property(): done update_symbol, modified=%d\n", xctx->modified);
xctx->edit_sym_i=-1; *ii=-1;
} }
/* x=0 use text widget x=1 use vim editor */ /* x=0 use text widget x=1 use vim editor */
@ -914,17 +915,19 @@ void update_symbol(const char *result, int x)
int cond; int cond;
int pushed=0; int pushed=0;
int s_pnetname; int s_pnetname;
int *ii = &xctx->edit_sym_i; /* static var */
int *netl_com = &xctx->netlist_commands; /* static var */
s_pnetname = tclgetboolvar("show_pin_net_names"); s_pnetname = tclgetboolvar("show_pin_net_names");
dbg(1, "update_symbol(): entering\n"); dbg(1, "update_symbol(): entering\n");
xctx->edit_sym_i=xctx->sel_array[0].n; *ii=xctx->sel_array[0].n;
if(!result) { if(!result) {
dbg(1, "update_symbol(): edit symbol prop aborted\n"); dbg(1, "update_symbol(): edit symbol prop aborted\n");
my_free(1289, &xctx->old_prop); my_free(1289, &xctx->old_prop);
return; return;
} }
/* create new_prop updated attribute string */ /* create new_prop updated attribute string */
if(xctx->netlist_commands && x==1) { if(*netl_com && x==1) {
my_strdup(79, &new_prop, my_strdup(79, &new_prop,
subst_token(xctx->old_prop, "value", (char *) tclgetvar("retval") ) subst_token(xctx->old_prop, "value", (char *) tclgetvar("retval") )
); );
@ -953,7 +956,7 @@ void update_symbol(const char *result, int x)
to use for inst name (from symbol template) */ to use for inst name (from symbol template) */
prefix=0; prefix=0;
sym_number = -1; sym_number = -1;
if(strcmp(symbol, xctx->inst[xctx->edit_sym_i].name)) { if(strcmp(symbol, xctx->inst[*ii].name)) {
set_modify(1); set_modify(1);
sym_number=match_symbol(symbol); /* check if exist */ sym_number=match_symbol(symbol); /* check if exist */
if(sym_number>=0) { if(sym_number>=0) {
@ -963,14 +966,14 @@ void update_symbol(const char *result, int x)
for(k=0;k<xctx->lastsel;k++) { for(k=0;k<xctx->lastsel;k++) {
dbg(1, "update_symbol(): for k loop: k=%d\n", k); dbg(1, "update_symbol(): for k loop: k=%d\n", k);
if(xctx->sel_array[k].type!=ELEMENT) continue; if(xctx->sel_array[k].type!=ELEMENT) continue;
xctx->edit_sym_i=xctx->sel_array[k].n; *ii=xctx->sel_array[k].n;
if(s_pnetname || xctx->hilight_nets) { if(s_pnetname || xctx->hilight_nets) {
int j; int j;
prepare_netlist_structs(0); prepare_netlist_structs(0);
for(j = 0; j < (xctx->inst[xctx->edit_sym_i].ptr + xctx->sym)->rects[PINLAYER]; j++) { for(j = 0; j < (xctx->inst[*ii].ptr + xctx->sym)->rects[PINLAYER]; j++) {
if( xctx->inst[xctx->edit_sym_i].node && xctx->inst[xctx->edit_sym_i].node[j]) { if( xctx->inst[*ii].node && xctx->inst[*ii].node[j]) {
int_hash_lookup(xctx->node_redraw_table, xctx->inst[xctx->edit_sym_i].node[j], 0, XINSERT_NOREPLACE); int_hash_lookup(xctx->node_redraw_table, xctx->inst[*ii].node[j], 0, XINSERT_NOREPLACE);
} }
} }
find_inst_to_be_redrawn(); find_inst_to_be_redrawn();
@ -978,19 +981,19 @@ void update_symbol(const char *result, int x)
/* 20171220 calculate bbox before changes to correctly redraw areas */ /* 20171220 calculate bbox before changes to correctly redraw areas */
/* must be recalculated as cairo text extents vary with zoom factor. */ /* must be recalculated as cairo text extents vary with zoom factor. */
symbol_bbox(xctx->edit_sym_i, &xctx->inst[xctx->edit_sym_i].x1, &xctx->inst[xctx->edit_sym_i].y1, symbol_bbox(*ii, &xctx->inst[*ii].x1, &xctx->inst[*ii].y1,
&xctx->inst[xctx->edit_sym_i].x2, &xctx->inst[xctx->edit_sym_i].y2); &xctx->inst[*ii].x2, &xctx->inst[*ii].y2);
if(sym_number>=0) /* changing symbol ! */ if(sym_number>=0) /* changing symbol ! */
{ {
if(!pushed) { push_undo(); pushed=1;} if(!pushed) { push_undo(); pushed=1;}
delete_inst_node(xctx->edit_sym_i); /* 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 xctx->edit_sym_i might end up deleting non allocated data. */ /* changing ysmbol, otherwise *ii might end up deleting non allocated data. */
my_strdup(82, &xctx->inst[xctx->edit_sym_i].name, rel_sym_path(symbol)); my_strdup(82, &xctx->inst[*ii].name, rel_sym_path(symbol));
xctx->inst[xctx->edit_sym_i].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[xctx->edit_sym_i].x1, xctx->inst[xctx->edit_sym_i].y1, bbox(ADD, xctx->inst[*ii].x1, xctx->inst[*ii].y1,
xctx->inst[xctx->edit_sym_i].x2, xctx->inst[xctx->edit_sym_i].y2); xctx->inst[*ii].x2, xctx->inst[*ii].y2);
/* update property string from tcl dialog */ /* update property string from tcl dialog */
if(!no_change_props) if(!no_change_props)
@ -998,59 +1001,59 @@ void update_symbol(const char *result, int x)
dbg(1, "update_symbol(): no_change_props=%d\n", no_change_props); dbg(1, "update_symbol(): no_change_props=%d\n", no_change_props);
if(only_different) { if(only_different) {
char * ss=NULL; char * ss=NULL;
my_strdup(119, &ss, xctx->inst[xctx->edit_sym_i].prop_ptr); my_strdup(119, &ss, xctx->inst[*ii].prop_ptr);
if( set_different_token(&ss, new_prop, xctx->old_prop, 0, 0) ) { if( set_different_token(&ss, new_prop, xctx->old_prop, 0, 0) ) {
if(!pushed) { push_undo(); pushed=1;} if(!pushed) { push_undo(); pushed=1;}
my_strdup(111, &xctx->inst[xctx->edit_sym_i].prop_ptr, ss); my_strdup(111, &xctx->inst[*ii].prop_ptr, ss);
set_modify(1); set_modify(1);
} }
my_free(729, &ss); my_free(729, &ss);
} }
else { else {
if(new_prop) { if(new_prop) {
if(!xctx->inst[xctx->edit_sym_i].prop_ptr || strcmp(xctx->inst[xctx->edit_sym_i].prop_ptr, new_prop)) { if(!xctx->inst[*ii].prop_ptr || strcmp(xctx->inst[*ii].prop_ptr, new_prop)) {
dbg(1, "update_symbol(): changing prop: |%s| -> |%s|\n", dbg(1, "update_symbol(): changing prop: |%s| -> |%s|\n",
xctx->inst[xctx->edit_sym_i].prop_ptr, new_prop); xctx->inst[*ii].prop_ptr, new_prop);
if(!pushed) { push_undo(); pushed=1;} if(!pushed) { push_undo(); pushed=1;}
my_strdup(84, &xctx->inst[xctx->edit_sym_i].prop_ptr, new_prop); my_strdup(84, &xctx->inst[*ii].prop_ptr, new_prop);
set_modify(1); set_modify(1);
} }
} else { } else {
if(!pushed) { push_undo(); pushed=1;} if(!pushed) { push_undo(); pushed=1;}
my_strdup(86, &xctx->inst[xctx->edit_sym_i].prop_ptr, ""); my_strdup(86, &xctx->inst[*ii].prop_ptr, "");
set_modify(1); set_modify(1);
} }
} }
} }
/* if symbol changed ensure instance name (with new prefix char) is unique */ /* if symbol changed ensure instance name (with new prefix char) is unique */
/* preserve backslashes in name ----------------------------------->. */ /* preserve backslashes in name ----------------------------------->. */
my_strdup(152, &name, get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr, "name", 1)); my_strdup(152, &name, get_tok_value(xctx->inst[*ii].prop_ptr, "name", 1));
if(name && name[0] ) { if(name && name[0] ) {
dbg(1, "update_symbol(): prefix!='\\0', name=%s\n", name); dbg(1, "update_symbol(): prefix!='\\0', name=%s\n", name);
/* 20110325 only modify prefix if prefix not NUL */ /* 20110325 only modify prefix if prefix not NUL */
if(prefix) name[0]=prefix; /* change prefix if changing symbol type; */ if(prefix) name[0]=prefix; /* change prefix if changing symbol type; */
dbg(1, "update_symbol(): name=%s, inst[xctx->edit_sym_i].prop_ptr=%s\n", dbg(1, "update_symbol(): name=%s, inst[*ii].prop_ptr=%s\n",
name, xctx->inst[xctx->edit_sym_i].prop_ptr); name, xctx->inst[*ii].prop_ptr);
my_strdup(89, &ptr,subst_token(xctx->inst[xctx->edit_sym_i].prop_ptr, "name", name) ); my_strdup(89, &ptr,subst_token(xctx->inst[*ii].prop_ptr, "name", name) );
/* set name of current inst */ /* set name of current inst */
if(!pushed) { push_undo(); pushed=1;} if(!pushed) { push_undo(); pushed=1;}
if(!k) hash_all_names(xctx->edit_sym_i); if(!k) hash_all_names(*ii);
new_prop_string(xctx->edit_sym_i, ptr, k, tclgetboolvar("disable_unique_names")); /* set new prop_ptr */ new_prop_string(*ii, ptr, k, tclgetboolvar("disable_unique_names")); /* set new prop_ptr */
} }
my_strdup2(90, &xctx->inst[xctx->edit_sym_i].instname, my_strdup2(90, &xctx->inst[*ii].instname,
get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr, "name",0)); get_tok_value(xctx->inst[*ii].prop_ptr, "name",0));
type=xctx->sym[xctx->inst[xctx->edit_sym_i].ptr].type; type=xctx->sym[xctx->inst[*ii].ptr].type;
cond= !type || !IS_LABEL_SH_OR_PIN(type); cond= !type || !IS_LABEL_SH_OR_PIN(type);
if(cond) xctx->inst[xctx->edit_sym_i].flags |= 2; /* bit 1: flag for different textlayer for pin/labels */ if(cond) xctx->inst[*ii].flags |= 2; /* bit 1: flag for different textlayer for pin/labels */
else { else {
xctx->inst[xctx->edit_sym_i].flags &= ~2; xctx->inst[*ii].flags &= ~2;
my_strdup(880, &xctx->inst[xctx->edit_sym_i].lab, my_strdup(880, &xctx->inst[*ii].lab,
get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr, "lab",0)); get_tok_value(xctx->inst[*ii].prop_ptr, "lab",0));
} }
if(!strcmp(get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr,"highlight",0), "true")) if(!strcmp(get_tok_value(xctx->inst[*ii].prop_ptr,"highlight",0), "true"))
xctx->inst[xctx->edit_sym_i].flags |= 4; xctx->inst[*ii].flags |= 4;
else xctx->inst[xctx->edit_sym_i].flags &= ~4; else xctx->inst[*ii].flags &= ~4;
} /* end for(k=0;k<xctx->lastsel;k++) */ } /* end for(k=0;k<xctx->lastsel;k++) */
/* new symbol bbox after prop changes (may change due to text length) */ /* new symbol bbox after prop changes (may change due to text length) */
if(xctx->modified) { if(xctx->modified) {
@ -1061,17 +1064,17 @@ void update_symbol(const char *result, int x)
if(s_pnetname || xctx->hilight_nets) prepare_netlist_structs(0); if(s_pnetname || xctx->hilight_nets) prepare_netlist_structs(0);
for(k=0;k<xctx->lastsel;k++) { for(k=0;k<xctx->lastsel;k++) {
if(xctx->sel_array[k].type!=ELEMENT) continue; if(xctx->sel_array[k].type!=ELEMENT) continue;
xctx->edit_sym_i=xctx->sel_array[k].n; *ii=xctx->sel_array[k].n;
type=xctx->sym[xctx->inst[xctx->edit_sym_i].ptr].type; type=xctx->sym[xctx->inst[*ii].ptr].type;
symbol_bbox(xctx->edit_sym_i, &xctx->inst[xctx->edit_sym_i].x1, &xctx->inst[xctx->edit_sym_i].y1, symbol_bbox(*ii, &xctx->inst[*ii].x1, &xctx->inst[*ii].y1,
&xctx->inst[xctx->edit_sym_i].x2, &xctx->inst[xctx->edit_sym_i].y2); &xctx->inst[*ii].x2, &xctx->inst[*ii].y2);
bbox(ADD, xctx->inst[xctx->edit_sym_i].x1, xctx->inst[xctx->edit_sym_i].y1, bbox(ADD, xctx->inst[*ii].x1, xctx->inst[*ii].y1,
xctx->inst[xctx->edit_sym_i].x2, xctx->inst[xctx->edit_sym_i].y2); xctx->inst[*ii].x2, xctx->inst[*ii].y2);
if((s_pnetname || xctx->hilight_nets) && type && IS_LABEL_OR_PIN(type)) { if((s_pnetname || xctx->hilight_nets) && type && IS_LABEL_OR_PIN(type)) {
/* <<< do only .node[0] ? */ /* <<< do only .node[0] ? */
for(j = 0; j < (xctx->inst[xctx->edit_sym_i].ptr + xctx->sym)->rects[PINLAYER]; j++) { for(j = 0; j < (xctx->inst[*ii].ptr + xctx->sym)->rects[PINLAYER]; j++) {
if( xctx->inst[xctx->edit_sym_i].node && xctx->inst[xctx->edit_sym_i].node[j]) { if( xctx->inst[*ii].node && xctx->inst[*ii].node[j]) {
int_hash_lookup(xctx->node_redraw_table, xctx->inst[xctx->edit_sym_i].node[j], 0, XINSERT_NOREPLACE); int_hash_lookup(xctx->node_redraw_table, xctx->inst[*ii].node[j], 0, XINSERT_NOREPLACE);
} }
} }
} }

View File

@ -23,45 +23,20 @@
#include "xschem.h" #include "xschem.h"
#ifdef IN_MEMORY_UNDO #ifdef IN_MEMORY_UNDO
typedef struct
{
char *gptr;
char *vptr;
char *sptr;
char *kptr;
char *eptr;
int *lines;
int *rects;
int *polygons;
int *arcs;
int wires;
int texts;
int instances;
xLine **lptr;
xRect **bptr;
xPoly **pptr;
xArc **aptr;
xWire *wptr;
xText *tptr;
xInstance *iptr;
} Undo_slot;
static Undo_slot uslot[MAX_UNDO];
static int initialized=0;
void init_undo() void init_undo()
{ {
int slot; int slot;
for(slot=0;slot<MAX_UNDO; slot++) { for(slot=0;slot<MAX_UNDO; slot++) {
uslot[slot].lines=my_calloc(165, cadlayers, sizeof(int)); xctx->uslot[slot].lines=my_calloc(165, cadlayers, sizeof(int));
uslot[slot].rects=my_calloc(166, cadlayers, sizeof(int)); xctx->uslot[slot].rects=my_calloc(166, cadlayers, sizeof(int));
uslot[slot].arcs=my_calloc(167, cadlayers, sizeof(int)); xctx->uslot[slot].arcs=my_calloc(167, cadlayers, sizeof(int));
uslot[slot].polygons=my_calloc(168, cadlayers, sizeof(int)); xctx->uslot[slot].polygons=my_calloc(168, cadlayers, sizeof(int));
uslot[slot].lptr=my_calloc(169, cadlayers, sizeof(xLine *)); xctx->uslot[slot].lptr=my_calloc(169, cadlayers, sizeof(xLine *));
uslot[slot].bptr=my_calloc(170, cadlayers, sizeof(xRect *)); xctx->uslot[slot].bptr=my_calloc(170, cadlayers, sizeof(xRect *));
uslot[slot].aptr=my_calloc(171, cadlayers, sizeof(xArc *)); xctx->uslot[slot].aptr=my_calloc(171, cadlayers, sizeof(xArc *));
uslot[slot].pptr=my_calloc(172, cadlayers, sizeof(xPoly *)); xctx->uslot[slot].pptr=my_calloc(172, cadlayers, sizeof(xPoly *));
} }
} }
@ -70,11 +45,11 @@ void free_lines(int slot)
int i, c; int i, c;
for(c=0;c<cadlayers; c++) { for(c=0;c<cadlayers; c++) {
for(i=0;i<uslot[slot].lines[c]; i++) { for(i=0;i<xctx->uslot[slot].lines[c]; i++) {
my_free(783, &uslot[slot].lptr[c][i].prop_ptr); my_free(783, &xctx->uslot[slot].lptr[c][i].prop_ptr);
} }
my_free(784, &uslot[slot].lptr[c]); my_free(784, &xctx->uslot[slot].lptr[c]);
uslot[slot].lines[c] = 0; xctx->uslot[slot].lines[c] = 0;
} }
} }
@ -83,11 +58,11 @@ void free_rects(int slot)
int i, c; int i, c;
for(c=0;c<cadlayers; c++) { for(c=0;c<cadlayers; c++) {
for(i=0;i<uslot[slot].rects[c]; i++) { for(i=0;i<xctx->uslot[slot].rects[c]; i++) {
my_free(785, &uslot[slot].bptr[c][i].prop_ptr); my_free(785, &xctx->uslot[slot].bptr[c][i].prop_ptr);
} }
my_free(786, &uslot[slot].bptr[c]); my_free(786, &xctx->uslot[slot].bptr[c]);
uslot[slot].rects[c] = 0; xctx->uslot[slot].rects[c] = 0;
} }
} }
@ -96,14 +71,14 @@ void free_polygons(int slot)
int i, c; int i, c;
for(c=0;c<cadlayers; c++) { for(c=0;c<cadlayers; c++) {
for(i=0;i<uslot[slot].polygons[c]; i++) { for(i=0;i<xctx->uslot[slot].polygons[c]; i++) {
my_free(787, &uslot[slot].pptr[c][i].prop_ptr); my_free(787, &xctx->uslot[slot].pptr[c][i].prop_ptr);
my_free(788, &uslot[slot].pptr[c][i].x); my_free(788, &xctx->uslot[slot].pptr[c][i].x);
my_free(789, &uslot[slot].pptr[c][i].y); my_free(789, &xctx->uslot[slot].pptr[c][i].y);
my_free(790, &uslot[slot].pptr[c][i].selected_point); my_free(790, &xctx->uslot[slot].pptr[c][i].selected_point);
} }
my_free(791, &uslot[slot].pptr[c]); my_free(791, &xctx->uslot[slot].pptr[c]);
uslot[slot].polygons[c] = 0; xctx->uslot[slot].polygons[c] = 0;
} }
} }
@ -112,11 +87,11 @@ void free_arcs(int slot)
int i, c; int i, c;
for(c=0;c<cadlayers; c++) { for(c=0;c<cadlayers; c++) {
for(i=0;i<uslot[slot].arcs[c]; i++) { for(i=0;i<xctx->uslot[slot].arcs[c]; i++) {
my_free(792, &uslot[slot].aptr[c][i].prop_ptr); my_free(792, &xctx->uslot[slot].aptr[c][i].prop_ptr);
} }
my_free(793, &uslot[slot].aptr[c]); my_free(793, &xctx->uslot[slot].aptr[c]);
uslot[slot].arcs[c] = 0; xctx->uslot[slot].arcs[c] = 0;
} }
} }
@ -124,38 +99,38 @@ void free_wires(int slot)
{ {
int i; int i;
for(i=0;i<uslot[slot].wires; i++) { for(i=0;i<xctx->uslot[slot].wires; i++) {
my_free(794, &uslot[slot].wptr[i].prop_ptr); my_free(794, &xctx->uslot[slot].wptr[i].prop_ptr);
} }
my_free(795, &uslot[slot].wptr); my_free(795, &xctx->uslot[slot].wptr);
uslot[slot].wires = 0; xctx->uslot[slot].wires = 0;
} }
void free_texts(int slot) void free_texts(int slot)
{ {
int i; int i;
for(i=0;i<uslot[slot].texts; i++) { for(i=0;i<xctx->uslot[slot].texts; i++) {
my_free(796, &uslot[slot].tptr[i].prop_ptr); my_free(796, &xctx->uslot[slot].tptr[i].prop_ptr);
my_free(797, &uslot[slot].tptr[i].txt_ptr); my_free(797, &xctx->uslot[slot].tptr[i].txt_ptr);
my_free(798, &uslot[slot].tptr[i].font); my_free(798, &xctx->uslot[slot].tptr[i].font);
} }
my_free(799, &uslot[slot].tptr); my_free(799, &xctx->uslot[slot].tptr);
uslot[slot].texts = 0; xctx->uslot[slot].texts = 0;
} }
void free_instances(int slot) void free_instances(int slot)
{ {
int i; int i;
for(i=0;i<uslot[slot].instances; i++) { for(i=0;i<xctx->uslot[slot].instances; i++) {
my_free(800, &uslot[slot].iptr[i].name); my_free(800, &xctx->uslot[slot].iptr[i].name);
my_free(801, &uslot[slot].iptr[i].prop_ptr); my_free(801, &xctx->uslot[slot].iptr[i].prop_ptr);
my_free(802, &uslot[slot].iptr[i].instname); my_free(802, &xctx->uslot[slot].iptr[i].instname);
my_free(104, &uslot[slot].iptr[i].lab); my_free(104, &xctx->uslot[slot].iptr[i].lab);
} }
my_free(803, &uslot[slot].iptr); my_free(803, &xctx->uslot[slot].iptr);
uslot[slot].instances = 0; xctx->uslot[slot].instances = 0;
} }
void clear_undo(void) void clear_undo(void)
@ -164,7 +139,7 @@ void clear_undo(void)
xctx->cur_undo_ptr = 0; xctx->cur_undo_ptr = 0;
xctx->tail_undo_ptr = 0; xctx->tail_undo_ptr = 0;
xctx->head_undo_ptr = 0; xctx->head_undo_ptr = 0;
if(!initialized) return; if(!xctx->initialized) return;
for(slot=0; slot<MAX_UNDO; slot++) { for(slot=0; slot<MAX_UNDO; slot++) {
free_lines(slot); free_lines(slot);
free_rects(slot); free_rects(slot);
@ -182,14 +157,14 @@ void delete_undo(void)
clear_undo(); clear_undo();
for(slot=0;slot<MAX_UNDO; slot++) { for(slot=0;slot<MAX_UNDO; slot++) {
my_free(804, &uslot[slot].lines); my_free(804, &xctx->uslot[slot].lines);
my_free(805, &uslot[slot].rects); my_free(805, &xctx->uslot[slot].rects);
my_free(806, &uslot[slot].arcs); my_free(806, &xctx->uslot[slot].arcs);
my_free(807, &uslot[slot].polygons); my_free(807, &xctx->uslot[slot].polygons);
my_free(808, &uslot[slot].lptr); my_free(808, &xctx->uslot[slot].lptr);
my_free(809, &uslot[slot].bptr); my_free(809, &xctx->uslot[slot].bptr);
my_free(810, &uslot[slot].aptr); my_free(810, &xctx->uslot[slot].aptr);
my_free(811, &uslot[slot].pptr); my_free(811, &xctx->uslot[slot].pptr);
} }
} }
@ -199,17 +174,17 @@ void push_undo(void)
int slot, i, c; int slot, i, c;
if(xctx->no_undo)return; if(xctx->no_undo)return;
if(!initialized) { if(!xctx->initialized) {
initialized=1; xctx->initialized=1;
init_undo(); init_undo();
} }
slot = xctx->cur_undo_ptr%MAX_UNDO; slot = xctx->cur_undo_ptr%MAX_UNDO;
my_strdup(173, &uslot[slot].gptr, xctx->schvhdlprop); my_strdup(173, &xctx->uslot[slot].gptr, xctx->schvhdlprop);
my_strdup(174, &uslot[slot].vptr, xctx->schverilogprop); my_strdup(174, &xctx->uslot[slot].vptr, xctx->schverilogprop);
my_strdup(175, &uslot[slot].sptr, xctx->schprop); my_strdup(175, &xctx->uslot[slot].sptr, xctx->schprop);
my_strdup(359, &uslot[slot].kptr, xctx->schsymbolprop); my_strdup(359, &xctx->uslot[slot].kptr, xctx->schsymbolprop);
my_strdup(176, &uslot[slot].eptr, xctx->schtedaxprop); my_strdup(176, &xctx->uslot[slot].eptr, xctx->schtedaxprop);
free_lines(slot); free_lines(slot);
free_rects(slot); free_rects(slot);
@ -220,89 +195,89 @@ void push_undo(void)
free_instances(slot); free_instances(slot);
for(c=0;c<cadlayers;c++) { for(c=0;c<cadlayers;c++) {
uslot[slot].lines[c] = xctx->lines[c]; xctx->uslot[slot].lines[c] = xctx->lines[c];
uslot[slot].rects[c] = xctx->rects[c]; xctx->uslot[slot].rects[c] = xctx->rects[c];
uslot[slot].arcs[c] = xctx->arcs[c]; xctx->uslot[slot].arcs[c] = xctx->arcs[c];
uslot[slot].polygons[c] = xctx->polygons[c]; xctx->uslot[slot].polygons[c] = xctx->polygons[c];
uslot[slot].lptr[c] = my_calloc(177, xctx->lines[c], sizeof(xLine)); xctx->uslot[slot].lptr[c] = my_calloc(177, xctx->lines[c], sizeof(xLine));
uslot[slot].bptr[c] = my_calloc(178, xctx->rects[c], sizeof(xRect)); xctx->uslot[slot].bptr[c] = my_calloc(178, xctx->rects[c], sizeof(xRect));
uslot[slot].pptr[c] = my_calloc(179, xctx->polygons[c], sizeof(xPoly)); xctx->uslot[slot].pptr[c] = my_calloc(179, xctx->polygons[c], sizeof(xPoly));
uslot[slot].aptr[c] = my_calloc(180, xctx->arcs[c], sizeof(xArc)); xctx->uslot[slot].aptr[c] = my_calloc(180, xctx->arcs[c], sizeof(xArc));
} }
uslot[slot].wptr = my_calloc(181, xctx->wires, sizeof(xWire)); xctx->uslot[slot].wptr = my_calloc(181, xctx->wires, sizeof(xWire));
uslot[slot].tptr = my_calloc(182, xctx->texts, sizeof(xText)); xctx->uslot[slot].tptr = my_calloc(182, xctx->texts, sizeof(xText));
uslot[slot].iptr = my_calloc(183, xctx->instances, sizeof(xInstance)); xctx->uslot[slot].iptr = my_calloc(183, xctx->instances, sizeof(xInstance));
uslot[slot].texts = xctx->texts; xctx->uslot[slot].texts = xctx->texts;
uslot[slot].instances = xctx->instances; xctx->uslot[slot].instances = xctx->instances;
uslot[slot].wires = xctx->wires; xctx->uslot[slot].wires = xctx->wires;
for(c=0;c<cadlayers;c++) { for(c=0;c<cadlayers;c++) {
/* lines */ /* lines */
for(i=0;i<xctx->lines[c];i++) { for(i=0;i<xctx->lines[c];i++) {
uslot[slot].lptr[c][i] = xctx->line[c][i]; xctx->uslot[slot].lptr[c][i] = xctx->line[c][i];
uslot[slot].lptr[c][i].prop_ptr = NULL; xctx->uslot[slot].lptr[c][i].prop_ptr = NULL;
my_strdup(184, &uslot[slot].lptr[c][i].prop_ptr, xctx->line[c][i].prop_ptr); my_strdup(184, &xctx->uslot[slot].lptr[c][i].prop_ptr, xctx->line[c][i].prop_ptr);
} }
/* rects */ /* rects */
for(i=0;i<xctx->rects[c];i++) { for(i=0;i<xctx->rects[c];i++) {
uslot[slot].bptr[c][i] = xctx->rect[c][i]; xctx->uslot[slot].bptr[c][i] = xctx->rect[c][i];
uslot[slot].bptr[c][i].prop_ptr = NULL; xctx->uslot[slot].bptr[c][i].prop_ptr = NULL;
my_strdup(185, &uslot[slot].bptr[c][i].prop_ptr, xctx->rect[c][i].prop_ptr); my_strdup(185, &xctx->uslot[slot].bptr[c][i].prop_ptr, xctx->rect[c][i].prop_ptr);
} }
/* arcs */ /* arcs */
for(i=0;i<xctx->arcs[c];i++) { for(i=0;i<xctx->arcs[c];i++) {
uslot[slot].aptr[c][i] = xctx->arc[c][i]; xctx->uslot[slot].aptr[c][i] = xctx->arc[c][i];
uslot[slot].aptr[c][i].prop_ptr = NULL; xctx->uslot[slot].aptr[c][i].prop_ptr = NULL;
my_strdup(186, &uslot[slot].aptr[c][i].prop_ptr, xctx->arc[c][i].prop_ptr); my_strdup(186, &xctx->uslot[slot].aptr[c][i].prop_ptr, xctx->arc[c][i].prop_ptr);
} }
/*polygons */ /*polygons */
for(i=0;i<xctx->polygons[c];i++) { for(i=0;i<xctx->polygons[c];i++) {
int points = xctx->poly[c][i].points; int points = xctx->poly[c][i].points;
uslot[slot].pptr[c][i] = xctx->poly[c][i]; xctx->uslot[slot].pptr[c][i] = xctx->poly[c][i];
uslot[slot].pptr[c][i].prop_ptr = NULL; xctx->uslot[slot].pptr[c][i].prop_ptr = NULL;
uslot[slot].pptr[c][i].x = NULL; xctx->uslot[slot].pptr[c][i].x = NULL;
uslot[slot].pptr[c][i].y = NULL; xctx->uslot[slot].pptr[c][i].y = NULL;
uslot[slot].pptr[c][i].selected_point = NULL; xctx->uslot[slot].pptr[c][i].selected_point = NULL;
uslot[slot].pptr[c][i].x = my_malloc(187, points * sizeof(double)); xctx->uslot[slot].pptr[c][i].x = my_malloc(187, points * sizeof(double));
uslot[slot].pptr[c][i].y = my_malloc(188, points * sizeof(double)); xctx->uslot[slot].pptr[c][i].y = my_malloc(188, points * sizeof(double));
uslot[slot].pptr[c][i].selected_point = my_malloc(189, points * sizeof(unsigned short)); xctx->uslot[slot].pptr[c][i].selected_point = my_malloc(189, points * sizeof(unsigned short));
memcpy(uslot[slot].pptr[c][i].x, xctx->poly[c][i].x, points * sizeof(double)); memcpy(xctx->uslot[slot].pptr[c][i].x, xctx->poly[c][i].x, points * sizeof(double));
memcpy(uslot[slot].pptr[c][i].y, xctx->poly[c][i].y, points * sizeof(double)); memcpy(xctx->uslot[slot].pptr[c][i].y, xctx->poly[c][i].y, points * sizeof(double));
memcpy(uslot[slot].pptr[c][i].selected_point, xctx->poly[c][i].selected_point, memcpy(xctx->uslot[slot].pptr[c][i].selected_point, xctx->poly[c][i].selected_point,
points * sizeof(unsigned short)); points * sizeof(unsigned short));
my_strdup(190, &uslot[slot].pptr[c][i].prop_ptr, xctx->poly[c][i].prop_ptr); my_strdup(190, &xctx->uslot[slot].pptr[c][i].prop_ptr, xctx->poly[c][i].prop_ptr);
} }
} }
/* instances */ /* instances */
for(i=0;i<xctx->instances;i++) { for(i=0;i<xctx->instances;i++) {
uslot[slot].iptr[i] = xctx->inst[i]; xctx->uslot[slot].iptr[i] = xctx->inst[i];
uslot[slot].iptr[i].prop_ptr = NULL; xctx->uslot[slot].iptr[i].prop_ptr = NULL;
uslot[slot].iptr[i].name = NULL; xctx->uslot[slot].iptr[i].name = NULL;
uslot[slot].iptr[i].instname = NULL; xctx->uslot[slot].iptr[i].instname = NULL;
uslot[slot].iptr[i].lab = NULL; xctx->uslot[slot].iptr[i].lab = NULL;
uslot[slot].iptr[i].node = NULL; xctx->uslot[slot].iptr[i].node = NULL;
my_strdup(330, &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, &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, &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, &uslot[slot].iptr[i].name, xctx->inst[i].name); my_strdup(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++) {
uslot[slot].tptr[i] = xctx->text[i]; xctx->uslot[slot].tptr[i] = xctx->text[i];
uslot[slot].tptr[i].prop_ptr = NULL; xctx->uslot[slot].tptr[i].prop_ptr = NULL;
uslot[slot].tptr[i].txt_ptr = NULL; xctx->uslot[slot].tptr[i].txt_ptr = NULL;
uslot[slot].tptr[i].font = NULL; xctx->uslot[slot].tptr[i].font = NULL;
my_strdup(194, &uslot[slot].tptr[i].prop_ptr, xctx->text[i].prop_ptr); my_strdup(194, &xctx->uslot[slot].tptr[i].prop_ptr, xctx->text[i].prop_ptr);
my_strdup(195, &uslot[slot].tptr[i].txt_ptr, xctx->text[i].txt_ptr); my_strdup(195, &xctx->uslot[slot].tptr[i].txt_ptr, xctx->text[i].txt_ptr);
my_strdup(196, &uslot[slot].tptr[i].font, xctx->text[i].font); my_strdup(196, &xctx->uslot[slot].tptr[i].font, xctx->text[i].font);
} }
/* wires */ /* wires */
for(i=0;i<xctx->wires;i++) { for(i=0;i<xctx->wires;i++) {
uslot[slot].wptr[i] = xctx->wire[i]; xctx->uslot[slot].wptr[i] = xctx->wire[i];
uslot[slot].wptr[i].prop_ptr = NULL; xctx->uslot[slot].wptr[i].prop_ptr = NULL;
uslot[slot].wptr[i].node = NULL; xctx->uslot[slot].wptr[i].node = NULL;
my_strdup(197, &uslot[slot].wptr[i].prop_ptr, xctx->wire[i].prop_ptr); my_strdup(197, &xctx->uslot[slot].wptr[i].prop_ptr, xctx->wire[i].prop_ptr);
} }
@ -336,94 +311,94 @@ void pop_undo(int redo)
slot = xctx->cur_undo_ptr%MAX_UNDO; slot = xctx->cur_undo_ptr%MAX_UNDO;
clear_drawing(); clear_drawing();
unselect_all(); unselect_all();
my_strdup(198, &xctx->schvhdlprop, uslot[slot].gptr); my_strdup(198, &xctx->schvhdlprop, xctx->uslot[slot].gptr);
my_strdup(199, &xctx->schverilogprop, uslot[slot].vptr); my_strdup(199, &xctx->schverilogprop, xctx->uslot[slot].vptr);
my_strdup(200, &xctx->schprop, uslot[slot].sptr); my_strdup(200, &xctx->schprop, xctx->uslot[slot].sptr);
my_strdup(389, &xctx->schsymbolprop, uslot[slot].kptr); my_strdup(389, &xctx->schsymbolprop, xctx->uslot[slot].kptr);
my_strdup(201, &xctx->schtedaxprop, uslot[slot].eptr); my_strdup(201, &xctx->schtedaxprop, xctx->uslot[slot].eptr);
for(c=0;c<cadlayers;c++) { for(c=0;c<cadlayers;c++) {
/* lines */ /* lines */
xctx->maxl[c] = xctx->lines[c] = uslot[slot].lines[c]; xctx->maxl[c] = xctx->lines[c] = xctx->uslot[slot].lines[c];
xctx->line[c] = my_calloc(202, xctx->lines[c], sizeof(xLine)); xctx->line[c] = my_calloc(202, xctx->lines[c], sizeof(xLine));
for(i=0;i<xctx->lines[c];i++) { for(i=0;i<xctx->lines[c];i++) {
xctx->line[c][i] = uslot[slot].lptr[c][i]; xctx->line[c][i] = xctx->uslot[slot].lptr[c][i];
xctx->line[c][i].prop_ptr=NULL; xctx->line[c][i].prop_ptr=NULL;
my_strdup(203, &xctx->line[c][i].prop_ptr, uslot[slot].lptr[c][i].prop_ptr); my_strdup(203, &xctx->line[c][i].prop_ptr, xctx->uslot[slot].lptr[c][i].prop_ptr);
} }
/* rects */ /* rects */
xctx->maxr[c] = xctx->rects[c] = uslot[slot].rects[c]; xctx->maxr[c] = xctx->rects[c] = xctx->uslot[slot].rects[c];
xctx->rect[c] = my_calloc(204, xctx->rects[c], sizeof(xRect)); xctx->rect[c] = my_calloc(204, xctx->rects[c], sizeof(xRect));
for(i=0;i<xctx->rects[c];i++) { for(i=0;i<xctx->rects[c];i++) {
xctx->rect[c][i] = uslot[slot].bptr[c][i]; xctx->rect[c][i] = xctx->uslot[slot].bptr[c][i];
xctx->rect[c][i].prop_ptr=NULL; xctx->rect[c][i].prop_ptr=NULL;
my_strdup(205, &xctx->rect[c][i].prop_ptr, uslot[slot].bptr[c][i].prop_ptr); my_strdup(205, &xctx->rect[c][i].prop_ptr, xctx->uslot[slot].bptr[c][i].prop_ptr);
} }
/* arcs */ /* arcs */
xctx->maxa[c] = xctx->arcs[c] = uslot[slot].arcs[c]; xctx->maxa[c] = xctx->arcs[c] = xctx->uslot[slot].arcs[c];
xctx->arc[c] = my_calloc(206, xctx->arcs[c], sizeof(xArc)); xctx->arc[c] = my_calloc(206, xctx->arcs[c], sizeof(xArc));
for(i=0;i<xctx->arcs[c];i++) { for(i=0;i<xctx->arcs[c];i++) {
xctx->arc[c][i] = uslot[slot].aptr[c][i]; xctx->arc[c][i] = xctx->uslot[slot].aptr[c][i];
xctx->arc[c][i].prop_ptr=NULL; xctx->arc[c][i].prop_ptr=NULL;
my_strdup(207, &xctx->arc[c][i].prop_ptr, uslot[slot].aptr[c][i].prop_ptr); my_strdup(207, &xctx->arc[c][i].prop_ptr, xctx->uslot[slot].aptr[c][i].prop_ptr);
} }
/* polygons */ /* polygons */
xctx->maxp[c] = xctx->polygons[c] = uslot[slot].polygons[c]; xctx->maxp[c] = xctx->polygons[c] = xctx->uslot[slot].polygons[c];
xctx->poly[c] = my_calloc(208, xctx->polygons[c], sizeof(xPoly)); xctx->poly[c] = my_calloc(208, xctx->polygons[c], sizeof(xPoly));
for(i=0;i<xctx->polygons[c];i++) { for(i=0;i<xctx->polygons[c];i++) {
int points = uslot[slot].pptr[c][i].points; int points = xctx->uslot[slot].pptr[c][i].points;
xctx->poly[c][i] = uslot[slot].pptr[c][i]; xctx->poly[c][i] = xctx->uslot[slot].pptr[c][i];
xctx->poly[c][i].prop_ptr=NULL; xctx->poly[c][i].prop_ptr=NULL;
xctx->poly[c][i].x=NULL; xctx->poly[c][i].x=NULL;
xctx->poly[c][i].y=NULL; xctx->poly[c][i].y=NULL;
xctx->poly[c][i].selected_point=NULL; xctx->poly[c][i].selected_point=NULL;
my_strdup(209, &xctx->poly[c][i].prop_ptr, uslot[slot].pptr[c][i].prop_ptr); my_strdup(209, &xctx->poly[c][i].prop_ptr, xctx->uslot[slot].pptr[c][i].prop_ptr);
my_realloc(210, &xctx->poly[c][i].x, points * sizeof(double)); my_realloc(210, &xctx->poly[c][i].x, points * sizeof(double));
my_realloc(211, &xctx->poly[c][i].y, points * sizeof(double)); my_realloc(211, &xctx->poly[c][i].y, points * sizeof(double));
my_realloc(212, &xctx->poly[c][i].selected_point, points * sizeof(unsigned short)); my_realloc(212, &xctx->poly[c][i].selected_point, points * sizeof(unsigned short));
memcpy(xctx->poly[c][i].x, uslot[slot].pptr[c][i].x, points * sizeof(double)); memcpy(xctx->poly[c][i].x, xctx->uslot[slot].pptr[c][i].x, points * sizeof(double));
memcpy(xctx->poly[c][i].y, uslot[slot].pptr[c][i].y, points * sizeof(double)); memcpy(xctx->poly[c][i].y, xctx->uslot[slot].pptr[c][i].y, points * sizeof(double));
memcpy(xctx->poly[c][i].selected_point, uslot[slot].pptr[c][i].selected_point, memcpy(xctx->poly[c][i].selected_point, xctx->uslot[slot].pptr[c][i].selected_point,
points * sizeof(unsigned short)); points * sizeof(unsigned short));
} }
} }
/* instances */ /* instances */
xctx->maxi = xctx->instances = uslot[slot].instances; xctx->maxi = xctx->instances = xctx->uslot[slot].instances;
xctx->inst = my_calloc(213, xctx->instances, sizeof(xInstance)); xctx->inst = my_calloc(213, xctx->instances, sizeof(xInstance));
for(i=0;i<xctx->instances;i++) { for(i=0;i<xctx->instances;i++) {
xctx->inst[i] = uslot[slot].iptr[i]; xctx->inst[i] = xctx->uslot[slot].iptr[i];
xctx->inst[i].prop_ptr=NULL; xctx->inst[i].prop_ptr=NULL;
xctx->inst[i].name=NULL; xctx->inst[i].name=NULL;
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, 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, uslot[slot].iptr[i].name); my_strdup(215, &xctx->inst[i].name, xctx->uslot[slot].iptr[i].name);
my_strdup2(216, &xctx->inst[i].instname, 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, uslot[slot].iptr[i].lab); my_strdup(766, &xctx->inst[i].lab, xctx->uslot[slot].iptr[i].lab);
} }
/* texts */ /* texts */
xctx->maxt = xctx->texts = uslot[slot].texts; xctx->maxt = xctx->texts = xctx->uslot[slot].texts;
xctx->text = my_calloc(217, xctx->texts, sizeof(xText)); xctx->text = my_calloc(217, xctx->texts, sizeof(xText));
for(i=0;i<xctx->texts;i++) { for(i=0;i<xctx->texts;i++) {
xctx->text[i] = uslot[slot].tptr[i]; xctx->text[i] = xctx->uslot[slot].tptr[i];
xctx->text[i].txt_ptr=NULL; xctx->text[i].txt_ptr=NULL;
xctx->text[i].font=NULL; xctx->text[i].font=NULL;
xctx->text[i].prop_ptr=NULL; xctx->text[i].prop_ptr=NULL;
my_strdup(218, &xctx->text[i].prop_ptr, uslot[slot].tptr[i].prop_ptr); my_strdup(218, &xctx->text[i].prop_ptr, xctx->uslot[slot].tptr[i].prop_ptr);
my_strdup(219, &xctx->text[i].txt_ptr, uslot[slot].tptr[i].txt_ptr); my_strdup(219, &xctx->text[i].txt_ptr, xctx->uslot[slot].tptr[i].txt_ptr);
my_strdup(220, &xctx->text[i].font, uslot[slot].tptr[i].font); my_strdup(220, &xctx->text[i].font, xctx->uslot[slot].tptr[i].font);
} }
/* wires */ /* wires */
xctx->maxw = xctx->wires = uslot[slot].wires; xctx->maxw = xctx->wires = xctx->uslot[slot].wires;
xctx->wire = my_calloc(221, xctx->wires, sizeof(xWire)); xctx->wire = my_calloc(221, xctx->wires, sizeof(xWire));
for(i=0;i<xctx->wires;i++) { for(i=0;i<xctx->wires;i++) {
xctx->wire[i] = uslot[slot].wptr[i]; xctx->wire[i] = xctx->uslot[slot].wptr[i];
xctx->wire[i].prop_ptr=NULL; xctx->wire[i].prop_ptr=NULL;
xctx->wire[i].node=NULL; xctx->wire[i].node=NULL;
my_strdup(222, &xctx->wire[i].prop_ptr, uslot[slot].wptr[i].prop_ptr); my_strdup(222, &xctx->wire[i].prop_ptr, xctx->uslot[slot].wptr[i].prop_ptr);
} }
link_symbols_to_instances(-1); link_symbols_to_instances(-1);

View File

@ -82,14 +82,14 @@ char *read_line(FILE *fp, int dbg_level)
/* */ /* */
/* return "/<prefix><random string of random_size characters>" */ /* return "/<prefix><random string of random_size characters>"
/* example: "/xschem_undo_dj5hcG38T2" */ * example: "/xschem_undo_dj5hcG38T2"
/* */ */
const char *random_string(const char *prefix) const char *random_string(const char *prefix)
{ {
static const char charset[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static const char charset[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static int random_size=10; static const int random_size=10;
static char str[PATH_MAX]; static char str[PATH_MAX]; /* safe even with multiple schematics, if immediately copied */
int prefix_size; int prefix_size;
static unsigned short once=1; static unsigned short once=1;
int i; int i;
@ -112,14 +112,14 @@ const char *random_string(const char *prefix)
/* */ /* */
/* try to create a tmp directory in $HOME */ /* try to create a tmp directory in XSCHEM_TMP_DIR */
/* ${HOME}/<prefix><trailing random chars> */ /* XSCHEM_TMP_DIR/<prefix><trailing random chars> */
/* after 5 unsuccessfull attemps give up */ /* after 5 unsuccessfull attemps give up */
/* and return NULL */ /* and return NULL */
/* */ /* */
const char *create_tmpdir(char *prefix) const char *create_tmpdir(char *prefix)
{ {
static char str[PATH_MAX]; static char str[PATH_MAX]; /* safe even with multiple schematics if immediately copied */
int i; int i;
struct stat buf; struct stat buf;
for(i=0; i<5;i++) { for(i=0; i<5;i++) {
@ -144,7 +144,7 @@ const char *create_tmpdir(char *prefix)
/* */ /* */
FILE *open_tmpfile(char *prefix, char **filename) FILE *open_tmpfile(char *prefix, char **filename)
{ {
static char str[PATH_MAX]; static char str[PATH_MAX]; /* safe even with multiple schematics, if immediately copied */
int i; int i;
FILE *fd; FILE *fd;
struct stat buf; struct stat buf;

View File

@ -581,6 +581,9 @@ void alloc_xschem_data(const char *top_path)
xctx->fill_type=my_calloc(640, cadlayers, sizeof(int)); xctx->fill_type=my_calloc(640, cadlayers, sizeof(int));
xctx->fill_pattern = 1; xctx->fill_pattern = 1;
xctx->draw_window = 0; xctx->draw_window = 0;
#ifdef IN_MEMORY_UNDO
xctx->initialized = 0; /* in_memory_undo */
#endif
} }
void delete_schematic_data(void) void delete_schematic_data(void)

View File

@ -501,6 +501,29 @@ struct simdata {
int npin; int npin;
}; };
typedef struct
{
char *gptr;
char *vptr;
char *sptr;
char *kptr;
char *eptr;
int *lines;
int *rects;
int *polygons;
int *arcs;
int wires;
int texts;
int instances;
xLine **lptr;
xRect **bptr;
xPoly **pptr;
xArc **aptr;
xWire *wptr;
xText *tptr;
xInstance *iptr;
} Undo_slot;
typedef struct { typedef struct {
xWire *wire; xWire *wire;
xText *text; xText *text;
@ -651,6 +674,11 @@ typedef struct {
char *old_prop; char *old_prop;
int edit_sym_i; int edit_sym_i;
int netlist_commands; int netlist_commands;
#ifdef IN_MEMORY_UNDO
/* in_memory_undo */
Undo_slot uslot[MAX_UNDO];
int initialized;
#endif
/* */ /* */
int nl_sel, nl_sem; int nl_sel, nl_sem;
XSegment *biggridpoint; XSegment *biggridpoint;