code cleanup

This commit is contained in:
Stefan Frederik 2022-10-08 10:07:59 +02:00
parent 4e6513e713
commit 03d2e685fe
4 changed files with 34 additions and 20 deletions

View File

@ -61,4 +61,8 @@ xinit.c \
print
} else print
prev = $1
}'
}
END{
print ">>>>>>>>>>> FREE >>>>>>>>> " n " ..."
}
'

View File

@ -1011,8 +1011,8 @@ static void name_pass_through_nets(int for_netlist)
int lev = 1;
dbg(1, "name_pass_through_nets() start...\n");
pt_symbol = my_calloc(973, xctx->symbols, sizeof(int));
symtable = my_calloc(1581, xctx->symbols, sizeof(int));
pt_symbol = my_calloc(0, xctx->symbols, sizeof(int));
symtable = my_calloc(0, xctx->symbols, sizeof(int));
/* we can not loop over xctx->symbols since we keep symbols of parent circuit while netlisting */
for(i = 0; i < xctx->instances; i++) {
k = xctx->inst[i].ptr;
@ -1034,9 +1034,9 @@ static void name_pass_through_nets(int for_netlist)
str_hash_free(&table);
if(pt_symbol[k]) dbg(1, "duplicated pins: %s\n", xctx->sym[i].name);
}
my_free(1582, &symtable);
my_free(0, &symtable);
if(!there_are_pt) { /* nothing to do: no pass through symbols */
my_free(1573, &pt_symbol);
my_free(0, &pt_symbol);
return;
}
do { /* keep looping until propagation of nets occurs */
@ -1047,7 +1047,7 @@ static void name_pass_through_nets(int for_netlist)
if(inst[i].ptr<0) continue;
if(!pt_symbol[ inst[i].ptr ]) continue;
str_hash_init(&table, 37);
my_strdup(1565, &type, (inst[i].ptr + xctx->sym)->type);
my_strdup(0, &type, (inst[i].ptr + xctx->sym)->type);
if (type && !IS_LABEL_OR_PIN(type) ) {
if ((rects = (inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0) {
/* 1st loop: hash symbol pins that are attached to named nets/pins/labels */
@ -1106,7 +1106,7 @@ static void name_pass_through_nets(int for_netlist)
iptr=iptr->next;
continue;
}
my_strdup(1566, &type2, (inst[iptr->n].ptr + xctx->sym)->type);
my_strdup(0, &type2, (inst[iptr->n].ptr + xctx->sym)->type);
if (!type2 || !IS_LABEL_OR_PIN(type2) ) {
iptr=iptr->next;
continue;
@ -1171,8 +1171,8 @@ static void name_pass_through_nets(int for_netlist)
dbg(lev, "inst %s pin %s(%s) --> net %s\n",
inst[i].instname, entry->token, entry->value,
xctx->wire[wptr->n].node ? xctx->wire[wptr->n].node : "<NULL>");
my_strdup(1568, &xctx->wire[wptr->n].node, entry->value);
my_strdup(1569, &xctx->wire[wptr->n].prop_ptr,
my_strdup(0, &xctx->wire[wptr->n].node, entry->value);
my_strdup(0, &xctx->wire[wptr->n].prop_ptr,
subst_token(xctx->wire[wptr->n].prop_ptr, "lab", entry->value));
wirecheck(wptr->n);
changed = 1;
@ -1186,9 +1186,9 @@ static void name_pass_through_nets(int for_netlist)
str_hash_free(&table);
} /* for (i=0;i<instances;i++) */
} while(changed);
my_free(1570, &type);
my_free(1571, &type2);
my_free(1572, &pt_symbol);
my_free(0, &type);
my_free(0, &type2);
my_free(0, &pt_symbol);
dbg(lev, "name_pass_through_nets() end...\n");
}

View File

@ -2758,6 +2758,16 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
case 't': /*----------------------------------------------*/
if(!strcmp(argv[1], "test"))
{
Ptr_hashtable table = {NULL, 0};
Ptr_hashentry *entry;
double a = 10.1;
ptr_hash_init(&table, 37);
ptr_hash_lookup(&table, "val", &a, XINSERT);
entry = ptr_hash_lookup(&table, "val", NULL, XLOOKUP);
dbg(0, "val=%g\n", *(double *)entry->value);
ptr_hash_free(&table);
Tcl_ResetResult(interp);
}

View File

@ -786,10 +786,10 @@ Ptr_hashentry *ptr_hash_lookup(Ptr_hashtable *hashtable, const char *token, void
if(what==XINSERT || what == XINSERT_NOREPLACE) /* insert data */
{
s=sizeof( Ptr_hashentry );
entry=(Ptr_hashentry *)my_malloc(659, s);
entry=(Ptr_hashentry *)my_malloc(253, s);
entry->next=NULL;
entry->token=NULL;
my_strdup(658, &entry->token, token);
my_strdup(252, &entry->token, token);
entry->value = value;
entry->hash=hashcode;
*preventry=entry;
@ -801,8 +801,8 @@ Ptr_hashentry *ptr_hash_lookup(Ptr_hashtable *hashtable, const char *token, void
if(what==XDELETE) /* remove token from the hash table ... */
{
saveptr=entry->next;
my_free(896, &entry->token);
my_free(897, &entry);
my_free(273, &entry->token);
my_free(274, &entry);
*preventry=saveptr;
}
else if(what == XINSERT ) {
@ -821,7 +821,7 @@ void ptr_hash_init(Ptr_hashtable *hashtable, int size)
dbg(0, "ptr_hash_init(): Warning hash table not empty, possible data leak\n");
}
hashtable->size = size;
hashtable->table = my_calloc(1576, size, sizeof(Ptr_hashentry *));
hashtable->table = my_calloc(1583, size, sizeof(Ptr_hashentry *));
}
static void ptr_hash_free_entry(Ptr_hashentry *entry)
@ -829,8 +829,8 @@ static void ptr_hash_free_entry(Ptr_hashentry *entry)
Ptr_hashentry *tmp;
while( entry ) {
tmp = entry -> next;
my_free(1171, &(entry->token));
my_free(1172, &entry);
my_free(1584, &(entry->token));
my_free(1585, &entry);
entry = tmp;
}
}
@ -846,7 +846,7 @@ void ptr_hash_free(Ptr_hashtable *hashtable)
ptr_hash_free_entry( table[i] );
table[i] = NULL;
}
my_free(1575, &(hashtable->table));
my_free(1586, &(hashtable->table));
hashtable->size = 0;
}
}