xctx->sch made an array of pointers instead of array of PATH_MAX strings (memory saver)
This commit is contained in:
parent
c97dfddd4e
commit
89d90c21db
|
|
@ -1884,7 +1884,7 @@ void go_back(int confirm) /* 20171006 add confirm */
|
|||
load_sym_def(xctx->sch[xctx->currsch], NULL);
|
||||
from_embedded_sym=1;
|
||||
}
|
||||
my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
if(xctx->portmap[xctx->currsch].table) str_hash_free(&xctx->portmap[xctx->currsch]);
|
||||
|
||||
xctx->sch_path_hash[xctx->currsch] = 0;
|
||||
|
|
@ -1935,7 +1935,7 @@ void clear_schematic(int cancel, int symbol)
|
|||
else my_snprintf(name, S(name), "%s-%d.sym", "untitled", i);
|
||||
if(stat(name, &buf)) break;
|
||||
}
|
||||
my_snprintf(xctx->sch[xctx->currsch], S(xctx->sch[xctx->currsch]), "%s/%s", pwd_dir, name);
|
||||
my_mstrcat(_ALLOC_ID_, &xctx->sch[xctx->currsch], pwd_dir, "/", name, NULL);
|
||||
my_strncpy(xctx->current_name, name, S(xctx->current_name));
|
||||
} else {
|
||||
xctx->netlist_type = CAD_SPICE_NETLIST;
|
||||
|
|
@ -1945,7 +1945,7 @@ void clear_schematic(int cancel, int symbol)
|
|||
else my_snprintf(name, S(name), "%s-%d.sch", "untitled", i);
|
||||
if(stat(name, &buf)) break;
|
||||
}
|
||||
my_snprintf(xctx->sch[xctx->currsch], S(xctx->sch[xctx->currsch]), "%s/%s", pwd_dir, name);
|
||||
my_mstrcat(_ALLOC_ID_, &xctx->sch[xctx->currsch], pwd_dir, "/", name, NULL);
|
||||
my_strncpy(xctx->current_name, name, S(xctx->current_name));
|
||||
}
|
||||
draw();
|
||||
|
|
|
|||
|
|
@ -2041,18 +2041,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
|
|||
}
|
||||
if(0 && (key=='u') && (state==ControlMask)) /* testmode */
|
||||
{
|
||||
int mult;
|
||||
remove_symbol(2);
|
||||
link_symbols_to_instances(-1);
|
||||
expandlabel("/RST", &mult);
|
||||
expandlabel("/CCC[3:0]", &mult);
|
||||
expandlabel("CCC[AA:BB:DD]", &mult);
|
||||
expandlabel("CCC[9:1:2]", &mult);
|
||||
expandlabel("CCC[10:BB:DD]", &mult);
|
||||
expandlabel("CCC[10..BB..DD]", &mult);
|
||||
expandlabel("CCC[10..0..2]", &mult);
|
||||
expandlabel("123", &mult);
|
||||
expandlabel("123AA", &mult);
|
||||
dbg(0, "%d\n", sizeof(Xschem_ctx));
|
||||
break;
|
||||
}
|
||||
if(key=='u' && state==0) /* undo */
|
||||
|
|
@ -2341,7 +2330,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
|
|||
check_unique_names(1);
|
||||
break;
|
||||
}
|
||||
if( 0 && (key==';') && (state & ControlMask) ) /* testmode: for performance testing */
|
||||
if( 0 && (key==';') && (state & ControlMask) ) /* testmode */
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,6 @@ void compile_font(void)
|
|||
clear_drawing();
|
||||
unselect_all(1);
|
||||
xctx->currsch = 0;
|
||||
my_strncpy(xctx->sch[xctx->currsch], "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
}
|
||||
|
||||
|
|
|
|||
10
src/save.c
10
src/save.c
|
|
@ -2330,7 +2330,7 @@ int save_schematic(const char *schname) /* 20171020 added return value */
|
|||
xRect *rect;
|
||||
int rects;
|
||||
|
||||
if( strcmp(schname,"") ) my_strncpy(xctx->sch[xctx->currsch], schname, S(xctx->sch[xctx->currsch]));
|
||||
if( strcmp(schname,"") ) my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], schname);
|
||||
else return 0;
|
||||
dbg(1, "save_schematic(): currsch=%d name=%s\n",xctx->currsch, schname);
|
||||
dbg(1, "save_schematic(): sch[currsch]=%s\n", xctx->sch[xctx->currsch]);
|
||||
|
|
@ -2443,7 +2443,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale
|
|||
my_snprintf(msg, S(msg), "get_directory {%s}", fname);
|
||||
my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname));
|
||||
/* local file name */
|
||||
my_strncpy(xctx->sch[xctx->currsch], name, S(xctx->sch[xctx->currsch]));
|
||||
my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], name);
|
||||
/* local relative reference */
|
||||
my_strncpy(xctx->current_name, rel_sym_path(name), S(xctx->current_name));
|
||||
|
||||
|
|
@ -2460,7 +2460,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale
|
|||
}
|
||||
|
||||
/* local file name */
|
||||
my_strncpy(xctx->sch[xctx->currsch], fname, S(xctx->sch[xctx->currsch]));
|
||||
my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], fname);
|
||||
/* local relative reference */
|
||||
my_strncpy(xctx->current_name, rel_sym_path(fname), S(xctx->current_name));
|
||||
} else { /* local file specified and not coming from web url */
|
||||
|
|
@ -2468,7 +2468,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale
|
|||
my_snprintf(msg, S(msg), "get_directory {%s}", fname);
|
||||
my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname));
|
||||
/* local file name */
|
||||
my_strncpy(xctx->sch[xctx->currsch], fname, S(xctx->sch[xctx->currsch]));
|
||||
my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], fname);
|
||||
/* local relative reference */
|
||||
my_strncpy(xctx->current_name, rel_sym_path(fname), S(xctx->current_name));
|
||||
}
|
||||
|
|
@ -2548,7 +2548,7 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo, int ale
|
|||
} else {
|
||||
my_strncpy(xctx->current_dirname, pwd_dir, S(xctx->current_dirname));
|
||||
}
|
||||
my_snprintf(xctx->sch[xctx->currsch], S(xctx->sch[xctx->currsch]), "%s/%s", xctx->current_dirname, name);
|
||||
my_mstrcat(_ALLOC_ID_, &xctx->sch[xctx->currsch], xctx->current_dirname, "/", name, NULL);
|
||||
if(reset_undo) set_modify(0);
|
||||
}
|
||||
check_collapsing_objects();
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void hier_psprint(char **res, int what) /* netlister driver */
|
|||
my_free(_ALLOC_ID_, &abs_path);
|
||||
str_hash_free(&subckt_table);
|
||||
my_free(_ALLOC_ID_, &subckt_name);
|
||||
my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
xctx->currsch--;
|
||||
unselect_all(1);
|
||||
xctx->pop_undo(4, 0);
|
||||
|
|
@ -430,7 +430,7 @@ int global_spice_netlist(int global) /* netlister driver */
|
|||
/* get_additional_symbols(0); */
|
||||
my_free(_ALLOC_ID_, &subckt_name);
|
||||
/*clear_drawing(); */
|
||||
my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
xctx->currsch--;
|
||||
unselect_all(1);
|
||||
dbg(1, "global_spice_netlist(): invoking pop_undo(0, 0)\n");
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ int global_tedax_netlist(int global) /* netlister driver */
|
|||
str_hash_free(&subckt_table);
|
||||
my_free(_ALLOC_ID_, &subckt_name);
|
||||
/*clear_drawing(); */
|
||||
my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
xctx->currsch--;
|
||||
unselect_all(1);
|
||||
xctx->pop_undo(4, 0);
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ int global_verilog_netlist(int global) /* netlister driver */
|
|||
/* get_additional_symbols(0); */
|
||||
str_hash_free(&subckt_table);
|
||||
my_free(_ALLOC_ID_, &subckt_name);
|
||||
my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
xctx->currsch--;
|
||||
unselect_all(1);
|
||||
xctx->pop_undo(4, 0);
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ int global_vhdl_netlist(int global) /* netlister driver */
|
|||
/* get_additional_symbols(0); */
|
||||
str_hash_free(&subckt_table);
|
||||
my_free(_ALLOC_ID_, &subckt_name);
|
||||
my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch]));
|
||||
my_free(_ALLOC_ID_, &xctx->sch[xctx->currsch]);
|
||||
xctx->currsch--;
|
||||
unselect_all(1);
|
||||
xctx->pop_undo(4, 0);
|
||||
|
|
|
|||
|
|
@ -365,6 +365,7 @@ static void free_xschem_data()
|
|||
my_free(_ALLOC_ID_, &xctx->sel_array);
|
||||
for(i=0;i<CADMAXHIER; ++i) {
|
||||
if(xctx->portmap[i].table) str_hash_free(&xctx->portmap[i]);
|
||||
if(xctx->sch[i]) my_free(_ALLOC_ID_, &xctx->sch[i]);
|
||||
if(xctx->sch_path[i]) my_free(_ALLOC_ID_, &xctx->sch_path[i]);
|
||||
if(xctx->hier_attr[i].templ) my_free(_ALLOC_ID_, &xctx->hier_attr[i].templ);
|
||||
if(xctx->hier_attr[i].prop_ptr) my_free(_ALLOC_ID_, &xctx->hier_attr[i].prop_ptr);
|
||||
|
|
@ -550,7 +551,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
|
|||
xctx->hilight_nets = 0;
|
||||
xctx->hilight_color = 0;
|
||||
for(i=0;i<CADMAXHIER; ++i) {
|
||||
xctx->sch[i][0] = '\0';
|
||||
xctx->sch[i] = NULL;
|
||||
xctx->sch_path[i]=NULL;
|
||||
xctx->sch_path_hash[i]=0;
|
||||
xctx->hier_attr[i].prop_ptr = NULL;
|
||||
|
|
|
|||
|
|
@ -850,7 +850,7 @@ typedef struct {
|
|||
char *schvhdlprop;
|
||||
char *schsymbolprop;
|
||||
char *schverilogprop;
|
||||
char sch[CADMAXHIER][PATH_MAX];
|
||||
char *sch[CADMAXHIER];
|
||||
int currsch;
|
||||
char *version_string;
|
||||
char *header_text; /* header text (license info) placed in the 'v' record after xschem/file version */
|
||||
|
|
|
|||
Loading…
Reference in New Issue