fix two small memory leaks, doc updates (xschem raw command) Raw.filename renamed to Raw.rawfile

This commit is contained in:
stefan schippers 2023-10-17 16:08:27 +02:00
parent 9fda2adccb
commit 306c5d0d15
7 changed files with 62 additions and 45 deletions

View File

@ -515,6 +515,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> abort_operation</kbd></li><pre>
@ -1023,6 +1024,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Debug: wrapper to propagate_hilights() function </pre>
<li><kbd> push_undo</kbd></li><pre>
Push current state on undo stack </pre>
<li><kbd> raw what [rawfile type]</kbd></li><pre>
what = read | clear | info | switch | switch_back
Load /clear / switch additional raw files </pre>
<li><kbd> raw_clear </kbd></li><pre>
Delete loaded simulation raw file </pre>
<li><kbd> raw_query loaded|value|index|values|datasets|vars|list </kbd></li><pre>
@ -1031,7 +1035,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
xschem raw_query datasets: get number of datasets (simulation runs)
xschem raw_query value node n: return n-th value of 'node' in raw file
xschem raw_query loaded: return hierarchy level
xschem raw_query filename: return raw filename
xschem raw_query rawfile: return raw filename
where raw file was loaded or -1 if no raw loaded
xschem raw_query index node: get index of simulation variable 'node'.
Example: raw_query index v(led) --&gt; 46
@ -1283,8 +1287,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
props is the attribute string
size sets the size
draw is a flag. If set to 1 will draw the created text </pre>
<li><kbd> test [rawfile type]</kbd></li><pre>
testmode </pre>
<li><kbd> toggle_colorscheme</kbd></li><pre>
Toggle dark/light colorscheme </pre>
<li><kbd> toggle_ignore</kbd></li><pre>
@ -1380,6 +1382,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"

View File

@ -36,6 +36,7 @@ char **parse_cmd_string(const char *cmd, int *argc)
static char *cmd_copy = NULL;
static char *argv[PARSE_SIZE];
char *cmd_ptr, *cmd_save;
dbg(1, "parse_cmd_string(): cmd=|%s|\n", cmd ? cmd : "NULL");
if(!cmd || !cmd[0]) {
if(cmd_copy) my_free(_ALLOC_ID_, &cmd_copy);
return NULL;
@ -47,7 +48,7 @@ char **parse_cmd_string(const char *cmd, int *argc)
cmd_ptr = NULL;
dbg(1, "--> %s\n", argv[*argc]);
(*argc)++;
if(*argc >= PARSE_SIZE) break;
if(*argc + 1 >= PARSE_SIZE) break; /* leave one element for the last NULL pointer */
}
argv[*argc] = NULL; /*terminating pointer needed by execvp() */
return argv;
@ -93,7 +94,7 @@ int filter_data(const char *din, const size_t ilen,
* p1
*/
fflush(NULL); /* flush all stdio streams before process forking */
if( (pid = fork()) == 0) {
if( (pid = fork()) == 0) { /* child process */
#if 1
char **av;
int ac;
@ -110,6 +111,7 @@ int filter_data(const char *din, const size_t ilen,
#if 1
av = parse_cmd_string(cmd, &ac);
parse_cmd_string(NULL, NULL); /* clear data */
if(execvp(av[0], av) == -1) {
#endif
@ -685,7 +687,7 @@ void free_rawfile(Raw **rawptr, int dr)
}
if(raw->sim_type) my_free(_ALLOC_ID_, &raw->sim_type);
if(raw->npoints) my_free(_ALLOC_ID_, &raw->npoints);
if(raw->filename) my_free(_ALLOC_ID_, &raw->filename);
if(raw->rawfile) my_free(_ALLOC_ID_, &raw->rawfile);
if(raw->schname) my_free(_ALLOC_ID_, &raw->schname);
if(raw->table.table) int_hash_free(&raw->table);
my_free(_ALLOC_ID_, rawptr);
@ -783,7 +785,7 @@ int raw_read(const char *f, Raw **rawptr, const char *type)
if(fd) {
if((res = read_dataset(fd, rawptr, type)) == 1) {
int i;
my_strdup2(_ALLOC_ID_, &raw->filename, f);
my_strdup2(_ALLOC_ID_, &raw->rawfile, f);
my_strdup2(_ALLOC_ID_, &raw->schname, xctx->sch[xctx->currsch]);
raw->level = xctx->currsch;
raw->allpoints = 0;
@ -827,7 +829,7 @@ int extra_rawfile(int what, const char *file, const char *type)
my_strncpy(f, tclresult(), S(f));
for(i = 0; i < xctx->extra_raw_n; i++) {
if(xctx->extra_raw_arr[i]->sim_type &&
!strcmp(xctx->extra_raw_arr[i]->filename, f) &&
!strcmp(xctx->extra_raw_arr[i]->rawfile, f) &&
!strcmp(xctx->extra_raw_arr[i]->sim_type, type)
) break;
}
@ -859,9 +861,9 @@ int extra_rawfile(int what, const char *file, const char *type)
tclvareval("subst {", file, "}", NULL);
my_strncpy(f, tclresult(), S(f));
for(i = 0; i < xctx->extra_raw_n; i++) {
dbg(1, " extra_rawfile(): checking with %s\n", xctx->extra_raw_arr[i]->filename);
dbg(1, " extra_rawfile(): checking with %s\n", xctx->extra_raw_arr[i]->rawfile);
if(xctx->extra_raw_arr[i]->sim_type &&
!strcmp(xctx->extra_raw_arr[i]->filename, f) &&
!strcmp(xctx->extra_raw_arr[i]->rawfile, f) &&
!strcmp(xctx->extra_raw_arr[i]->sim_type, type)
) break;
}
@ -903,7 +905,7 @@ int extra_rawfile(int what, const char *file, const char *type)
my_strncpy(f, tclresult(), S(f));
if(xctx->extra_raw_n > 1 ) {
for(i = 0; i < xctx->extra_raw_n; i++) {
if(!strcmp(xctx->extra_raw_arr[i]->filename, f)) {
if(!strcmp(xctx->extra_raw_arr[i]->rawfile, f)) {
free_rawfile(&xctx->extra_raw_arr[i], 0);
found = i;
continue;
@ -923,7 +925,7 @@ int extra_rawfile(int what, const char *file, const char *type)
dbg(1, "extra_raw_n = %d\n", xctx->extra_raw_n);
Tcl_AppendResult(interp, my_itoa(xctx->extra_idx), " current\n", NULL);
for(i = 0; i < xctx->extra_raw_n; i++) {
Tcl_AppendResult(interp, my_itoa(i), " ", xctx->extra_raw_arr[i]->filename, " ",
Tcl_AppendResult(interp, my_itoa(i), " ", xctx->extra_raw_arr[i]->rawfile, " ",
xctx->extra_raw_arr[i]->sim_type ? xctx->extra_raw_arr[i]->sim_type : "NULL", "\n", NULL);
}
}
@ -1056,7 +1058,7 @@ int table_read(const char *f)
raw->allpoints = 0;
if(res == 1) {
int i;
my_strdup2(_ALLOC_ID_, &raw->filename, f);
my_strdup2(_ALLOC_ID_, &raw->rawfile, f);
my_strdup2(_ALLOC_ID_, &raw->schname, xctx->sch[xctx->currsch]);
raw->level = xctx->currsch;
raw->allpoints = 0;

View File

@ -30,8 +30,8 @@ void statusmsg(char str[],int n)
if(!str) return;
if(str[0]== '\0') {
my_free(_ALLOC_ID_, &xctx->infowindow_text);
return;
} else {
if(n == 3) {
my_strdup(_ALLOC_ID_, &xctx->infowindow_text, str);
} else if(n == 2) {
@ -3125,7 +3125,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* xschem raw_query datasets: get number of datasets (simulation runs)
* xschem raw_query value node n: return n-th value of 'node' in raw file
* xschem raw_query loaded: return hierarchy level
* xschem raw_query filename: return raw filename
* xschem raw_query rawfile: return raw filename
* where raw file was loaded or -1 if no raw loaded
* xschem raw_query index node: get index of simulation variable 'node'.
* Example: raw_query index v(led) --> 46
@ -3199,8 +3199,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(dset >= 0 && dset < raw->datasets)
Tcl_SetResult(interp, my_itoa(raw->npoints[dset]), TCL_VOLATILE);
}
} else if(argc > 2 && !strcmp(argv[2], "filename")) {
Tcl_SetResult(interp, raw->filename, TCL_VOLATILE);
} else if(argc > 2 && !strcmp(argv[2], "rawfile")) {
Tcl_SetResult(interp, raw->rawfile, TCL_VOLATILE);
} else if(argc > 2 && !strcmp(argv[2], "vars")) {
Tcl_SetResult(interp, my_itoa(raw->nvars), TCL_VOLATILE);
} else if(argc > 2 && !strcmp(argv[2], "list")) {

View File

@ -674,6 +674,7 @@ static void delete_schematic_data(int delete_pixmap)
is_generator(NULL);
extra_rawfile(3, NULL, NULL);
free_rawfile(&xctx->raw, 0);
statusmsg("", 1); /* clear allocated string */
free_xschem_data(); /* delete the xctx struct */
}

View File

@ -767,7 +767,7 @@ struct hilight_hashentry
typedef struct {
/* spice raw file specific data */
char **names;
char *filename;
char *rawfile;
SPICE_DATA **values;
int nvars;
int *npoints;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long