fix a memory leak, spatial hash table tuning, better clear find_inst_to_be_redrawn() nodetable

This commit is contained in:
Stefan Schippers 2020-10-05 13:29:57 +02:00
parent 72363cf2d4
commit 11d664b4a8
7 changed files with 42 additions and 34 deletions

View File

@ -1675,9 +1675,9 @@ void new_wire(int what, double mx_snap, double my_snap)
update_conn_cues(1,1);
if(show_pin_net_names) {
prepare_netlist_structs(0);
find_inst_hash_clear();
bbox(BEGIN , 0.0 , 0.0 , 0.0 , 0.0);
find_inst_to_be_redrawn(wire[lastwire-1].node);
find_inst_hash_clear();
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);

View File

@ -949,12 +949,12 @@ void update_symbol(const char *result, int x)
bbox(BEGIN,0.0,0.0,0.0,0.0);
if(show_pin_net_names) {
prepare_netlist_structs(0);
find_inst_hash_clear();
for(k = 0; k < (inst_ptr[i].ptr + instdef)->rects[PINLAYER]; k++) {
if( inst_ptr[i].node && inst_ptr[i].node[k]) {
find_inst_to_be_redrawn(inst_ptr[i].node[k]);
}
}
find_inst_hash_clear();
}
/* 20191227 necessary? --> Yes since a symbol copy has already been done
@ -1103,12 +1103,12 @@ void update_symbol(const char *result, int x)
if(show_pin_net_names) {
prepare_netlist_structs(0);
find_inst_hash_clear();
for(k = 0; k < (inst_ptr[i].ptr + instdef)->rects[PINLAYER]; k++) {
if( inst_ptr[i].node && inst_ptr[i].node[k]) {
find_inst_to_be_redrawn(inst_ptr[i].node[k]);
}
}
find_inst_hash_clear();
}
/* redraw symbol with new props */

View File

@ -552,6 +552,7 @@ void copy_objects(int what)
}
if(what & END) /* copy selected objects */
{
int firstw, firsti;
int save_draw; /* 20181009 */
save_draw = draw_window;
draw_window=1; /* temporarily re-enable draw to window together with pixmap */
@ -559,27 +560,16 @@ void copy_objects(int what)
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0); /* 20181009 */
newpropcnt=0;
set_modify(1); push_undo(); /* 20150327 push_undo */
prepared_hash_instances=0; /* 20171224 */
prepared_hash_wires=0;
if(show_pin_net_names) find_inst_hash_clear();
/* calculate copied symbols bboxes before actually doing the move */
/*
for(i=0;i<lastselected;i++)
{
n = selectedgroup[i].n;
if( selectedgroup[i].type == ELEMENT) {
symbol_bbox(n, &inst_ptr[n].x1, &inst_ptr[n].y1, &inst_ptr[n].x2, &inst_ptr[n].y2 );
bbox(ADD, inst_ptr[n].x1, inst_ptr[n].y1, inst_ptr[n].x2, inst_ptr[n].y2 );
}
}
*/
firstw = firsti = 1;
for(i=0;i<lastselected;i++)
{
n = selectedgroup[i].n;
if(selectedgroup[i].type == WIRE)
{
if(firstw) {
prepared_hash_wires=0;
firstw = 0;
}
check_wire_storage();
/*
if(wire[n].bus){
@ -863,6 +853,10 @@ void copy_objects(int what)
break;
case ELEMENT:
if(k==0) {
if(firsti) {
prepared_hash_instances = 0;
firsti = 0;
}
check_inst_storage();
if(rotatelocal) {
@ -907,9 +901,10 @@ void copy_objects(int what)
* to translate @#n:net_name texts */
need_rebuild_selected_array=1;
rebuild_selected_array();
prepared_hash_wires=0;
prepared_netlist_structs=0;
prepared_hilight_structs=0;
if(!firsti || !firstw) {
prepared_netlist_structs=0;
prepared_hilight_structs=0;
}
if(show_pin_net_names) {
prepare_netlist_structs(0);
}
@ -933,6 +928,7 @@ void copy_objects(int what)
}
}
}
if(show_pin_net_names) find_inst_hash_clear();
filledrect(k, END, 0.0, 0.0, 0.0, 0.0);
drawarc(k, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0);
@ -1014,15 +1010,13 @@ void move_objects(int what, int merge, double dx, double dy)
}
if(what & END) /* move selected objects */
{
int firsti, firstw;
int save_draw; /* 20181009 */
save_draw = draw_window;
draw_window=1; /* temporarily re-enable draw to window together with pixmap */
draw_selection(gctiled,0);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
set_modify(1);
prepared_hash_instances=0; /* 20171224 */
prepared_hash_wires=0;
if(show_pin_net_names) find_inst_hash_clear();
if( !(ui_state & (STARTMERGE | PLACE_SYMBOL)) ) {
dbg(1, "move_objects(): push undo state\n");
push_undo(); /* 20150327 push_undo */
@ -1039,6 +1033,7 @@ void move_objects(int what, int merge, double dx, double dy)
}
/* calculate moving symbols bboxes before actually doing the move */
firsti = firstw = 1;
for(i=0;i<lastselected;i++)
{
n = selectedgroup[i].n;
@ -1056,6 +1051,7 @@ void move_objects(int what, int merge, double dx, double dy)
find_inst_to_be_redrawn(wire[n].node);
}
}
if(show_pin_net_names) find_inst_hash_clear();
for(k=0;k<cadlayers;k++)
{
for(i=0;i<lastselected;i++)
@ -1064,6 +1060,10 @@ void move_objects(int what, int merge, double dx, double dy)
switch(selectedgroup[i].type)
{
case WIRE:
if(firstw) {
prepared_hash_wires=0;
firstw = 0;
}
if(k == 0) {
if(wire[n].bus){ /* 20171201 */
int ov, y1, y2;
@ -1377,6 +1377,10 @@ void move_objects(int what, int merge, double dx, double dy)
case ELEMENT:
if(k==0) {
if(firsti) {
prepared_hash_instances=0;
firsti = 0;
}
if(rotatelocal) {
ROTATION(inst_ptr[n].x0, inst_ptr[n].y0, inst_ptr[n].x0, inst_ptr[n].y0, rx1,ry1);
} else {
@ -1396,9 +1400,10 @@ void move_objects(int what, int merge, double dx, double dy)
if(k == 0 ) {
/* force these vars to 0 to trigger a prepare_netlist_structs(0) needed by symbol_bbox->translate
* to translate @#n:net_name texts */
prepared_netlist_structs=0;
prepared_hilight_structs=0;
prepared_hash_wires=0;
if(!firsti || !firstw) {
prepared_netlist_structs=0;
prepared_hilight_structs=0;
}
if(show_pin_net_names) {
prepare_netlist_structs(0);
}
@ -1422,6 +1427,7 @@ void move_objects(int what, int merge, double dx, double dy)
}
/* draw_symbol(ADD,k, n,k, 0, 0, 0.0, 0.0); */
}
if(show_pin_net_names) find_inst_hash_clear();
filledrect(k, END, 0.0, 0.0, 0.0, 0.0);
drawarc(k, END, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0);

View File

@ -227,7 +227,6 @@ void delete(void)
prepared_hilight_structs=0;
*/
if(show_pin_net_names) {
find_inst_hash_clear();
prepare_netlist_structs(0);
}
for(i = 0; i < lastselected; i++) {
@ -247,6 +246,9 @@ void delete(void)
find_inst_to_be_redrawn(wire[n].node);
}
}
if(show_pin_net_names) {
find_inst_hash_clear();
}

View File

@ -2661,8 +2661,8 @@ const char *translate(int inst, char* s)
slot = atoi(tmpstr);
if(strstr(value,":")) value = find_nth(value, ':', slot);
}
my_free(1177, &tmpstr);
}
my_free(1177, &tmpstr);
}
tmp=strlen(value);
if(result_pos + tmp>=size) {

View File

@ -198,8 +198,8 @@ extern char win_temp_dir[PATH_MAX];
#define ARC 64
/* for netlist.c */
#define BOXSIZE 3000
#define NBOXES 40
#define BOXSIZE 400
#define NBOXES 100
#define MAX_UNDO 80

View File

@ -17,8 +17,8 @@ N 60 -230 100 -230 {lab=A}
N 140 -230 190 -230 {lab=Z}
N 140 -340 140 -320 {lab=VDD}
N 140 -140 140 -120 {lab=0}
C {nmos4.sym} 120 -170 0 0 {name=M1 model=n w=WN l=LLN m=1}
C {pmos4.sym} 120 -290 0 0 {name=M2 model=p w=WP l=LLP m=1}
C {nmos4.sym} 120 -170 0 0 {name=M1 model=n w=WN l=LLN m=1 net_name=true}
C {pmos4.sym} 120 -290 0 0 {name=M2 model=p w=WP l=LLP m=1 net_name=true}
C {vdd.sym} 140 -340 0 0 {name=l1 lab=VDD}
C {lab_pin.sym} 140 -120 0 0 {name=l2 sig_type=std_logic lab=0}
C {ipin.sym} 60 -230 0 0 {name=p1 lab=A}