|
|
|
@ -130,7 +130,7 @@ readline(FILE *fd) |
|
|
|
strptr = NULL; |
|
|
|
strlen = 0; |
|
|
|
memlen = STRGROW; |
|
|
|
strptr = (char*) tmalloc(memlen); |
|
|
|
strptr = TMALLOC(char, memlen); |
|
|
|
memlen -= 1; /* Save constant -1's in while loop */ |
|
|
|
while((c = getc(fd)) != EOF) { |
|
|
|
if (strlen == 0 && (c == '\t' || c == ' ')) /* Leading spaces away */ |
|
|
|
@ -139,7 +139,7 @@ readline(FILE *fd) |
|
|
|
strlen++; |
|
|
|
if( strlen >= memlen ) { |
|
|
|
memlen += STRGROW; |
|
|
|
if( !(strptr = (char*) trealloc(strptr, (memlen + 1)*sizeof(char)))) { |
|
|
|
if( !(strptr = TREALLOC(char, strptr, memlen + 1))) { |
|
|
|
return (NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -153,7 +153,7 @@ readline(FILE *fd) |
|
|
|
} |
|
|
|
// strptr[strlen] = '\0'; |
|
|
|
/* Trim the string */ |
|
|
|
strptr = (char*) trealloc(strptr, (strlen + 1)*sizeof(char)); |
|
|
|
strptr = TREALLOC(char, strptr, strlen + 1); |
|
|
|
strptr[strlen] = '\0'; |
|
|
|
return (strptr); |
|
|
|
} |
|
|
|
@ -400,7 +400,7 @@ inp_add_control_section( struct line *deck, int *line_number ) { |
|
|
|
found_run = TRUE; |
|
|
|
} |
|
|
|
if ( cp_getvar( "rawfile", CP_STRING, rawfile ) ) { |
|
|
|
line = (char*) tmalloc( strlen("write") + strlen(rawfile) + 2 ); |
|
|
|
line = TMALLOC(char, strlen("write") + strlen(rawfile) + 2); |
|
|
|
sprintf(line, "write %s", rawfile); |
|
|
|
newcard = create_new_card( line, line_number ); |
|
|
|
prev_card->li_next = newcard; |
|
|
|
@ -419,7 +419,7 @@ inp_add_control_section( struct line *deck, int *line_number ) { |
|
|
|
newcard->li_next = prev_card; |
|
|
|
|
|
|
|
if ( cp_getvar( "rawfile", CP_STRING, rawfile ) ) { |
|
|
|
line = (char*) tmalloc( strlen("write") + strlen(rawfile) + 2 ); |
|
|
|
line = TMALLOC(char, strlen("write") + strlen(rawfile) + 2); |
|
|
|
sprintf(line, "write %s", rawfile); |
|
|
|
prev_card = deck->li_next; |
|
|
|
newcard = create_new_card( line, line_number ); |
|
|
|
@ -486,10 +486,10 @@ inp_fix_macro_param_func_paren_io( struct line *begin_card ) { |
|
|
|
while( !isspace(*str_ptr) ) str_ptr++; |
|
|
|
|
|
|
|
if ( ciprefix( ".macro", card->li_line ) ) { |
|
|
|
new_str = (char*) tmalloc( strlen(".subckt") + strlen(str_ptr) + 1 ); |
|
|
|
new_str = TMALLOC(char, strlen(".subckt") + strlen(str_ptr) + 1); |
|
|
|
sprintf( new_str, ".subckt%s", str_ptr ); |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen(".ends") + strlen(str_ptr) + 1 ); |
|
|
|
new_str = TMALLOC(char, strlen(".ends") + strlen(str_ptr) + 1); |
|
|
|
sprintf( new_str, ".ends%s", str_ptr ); |
|
|
|
} |
|
|
|
|
|
|
|
@ -751,8 +751,8 @@ comment_out_unused_subckt_models( struct line *start_card , int no_of_lines) |
|
|
|
/* generate arrays of *char for subckt or model names. Start |
|
|
|
with 1000, but increase, if number of lines in deck is larger */ |
|
|
|
if (no_of_lines < 1000) no_of_lines = 1000; |
|
|
|
used_subckt_names = (char**)tmalloc(no_of_lines*sizeof(char*)); |
|
|
|
used_model_names = (char**)tmalloc(no_of_lines*sizeof(char*)); |
|
|
|
used_subckt_names = TMALLOC(char*, no_of_lines); |
|
|
|
used_model_names = TMALLOC(char*, no_of_lines); |
|
|
|
|
|
|
|
for ( card = start_card; card != NULL; card = card->li_next ) { |
|
|
|
if ( ciprefix( ".model", card->li_line ) ) has_models = TRUE; |
|
|
|
@ -1005,19 +1005,19 @@ inp_fix_ternary_operator_str( char *line ) |
|
|
|
|
|
|
|
if ( end_str != NULL ) { |
|
|
|
if ( beg_str != NULL ) { |
|
|
|
new_str = (char*) tmalloc( strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5); |
|
|
|
sprintf( new_str, "%sternary_fcn(%s,%s,%s)%s", beg_str, conditional, if_str, else_str, end_str ); |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + strlen(end_str) + 5); |
|
|
|
sprintf( new_str, "ternary_fcn(%s,%s,%s)%s", conditional, if_str, else_str, end_str ); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if ( beg_str != NULL ) { |
|
|
|
new_str = (char*) tmalloc( strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen(beg_str) + strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5); |
|
|
|
sprintf( new_str, "%sternary_fcn(%s,%s,%s)", beg_str, conditional, if_str, else_str ); |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen("ternary_fcn") + strlen(conditional) + strlen(if_str) + strlen(else_str) + 5); |
|
|
|
sprintf( new_str, "ternary_fcn(%s,%s,%s)", conditional, if_str, else_str ); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1115,7 +1115,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c |
|
|
|
if ( call_depth == 0 && line_count == 0 ) { |
|
|
|
line_count++; |
|
|
|
if ( fgets( big_buff, 5000, fp ) ) { |
|
|
|
/* buffer = (char*) tmalloc( strlen(big_buff) + 1 ); |
|
|
|
/* buffer = TMALLOC(char, strlen(big_buff) + 1); |
|
|
|
strcpy(buffer, big_buff); */ |
|
|
|
buffer = copy(big_buff); |
|
|
|
} |
|
|
|
@ -1137,7 +1137,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c |
|
|
|
break; |
|
|
|
} |
|
|
|
else if(ipc_status == IPC_STATUS_OK) { |
|
|
|
buffer = (char *) tmalloc(strlen(ipc_buffer) + 3); |
|
|
|
buffer = TMALLOC(char, strlen(ipc_buffer) + 3); |
|
|
|
strcpy(buffer, ipc_buffer); |
|
|
|
strcat(buffer, "\n"); |
|
|
|
} |
|
|
|
@ -1375,7 +1375,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c |
|
|
|
} |
|
|
|
|
|
|
|
if ( shell_eol_continuation ) { |
|
|
|
char *new_buffer = (char*) tmalloc( strlen(buffer) + 2); |
|
|
|
char *new_buffer = TMALLOC(char, strlen(buffer) + 2); |
|
|
|
sprintf( new_buffer, "+%s", buffer ); |
|
|
|
|
|
|
|
tfree(buffer); |
|
|
|
@ -1410,7 +1410,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c |
|
|
|
|
|
|
|
if ( call_depth == 0 && found_end == TRUE) { |
|
|
|
if ( global == NULL ) { |
|
|
|
global = (char*) tmalloc( strlen(".global gnd") + 1 ); |
|
|
|
global = TMALLOC(char, strlen(".global gnd") + 1); |
|
|
|
sprintf( global, ".global gnd" ); |
|
|
|
} |
|
|
|
global_card = alloc(struct line); |
|
|
|
@ -1507,7 +1507,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c |
|
|
|
end->li_next = alloc(struct line); /* create next card */ |
|
|
|
end = end->li_next; /* point to next card */ |
|
|
|
|
|
|
|
buffer = (char*) tmalloc( strlen( ".end" ) + 1 ); |
|
|
|
buffer = TMALLOC(char, strlen( ".end" ) + 1); |
|
|
|
sprintf( buffer, ".end" ); |
|
|
|
|
|
|
|
/* now put buffer into li */ |
|
|
|
@ -1565,7 +1565,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c |
|
|
|
} |
|
|
|
|
|
|
|
/* create buffer and write last and current line into it. */ |
|
|
|
buffer = (char*) tmalloc(strlen(prev->li_line) + strlen(s) + 2); |
|
|
|
buffer = TMALLOC(char, strlen(prev->li_line) + strlen(s) + 2); |
|
|
|
(void) sprintf(buffer, "%s %s", prev->li_line, s + 1); |
|
|
|
|
|
|
|
s = prev->li_line; |
|
|
|
@ -1893,7 +1893,7 @@ inp_fix_subckt( char *s ) |
|
|
|
if ( new_str == NULL ) new_str = strdup(c->li_line); |
|
|
|
else { |
|
|
|
str = new_str; |
|
|
|
new_str = (char*) tmalloc( strlen(str) + strlen(c->li_line) + 2 ); |
|
|
|
new_str = TMALLOC(char, strlen(str) + strlen(c->li_line) + 2); |
|
|
|
sprintf( new_str, "%s %s", str, c->li_line ); |
|
|
|
tfree(str); |
|
|
|
} |
|
|
|
@ -1904,7 +1904,7 @@ inp_fix_subckt( char *s ) |
|
|
|
} |
|
|
|
|
|
|
|
/* create buffer and insert params: */ |
|
|
|
buffer = (char*) tmalloc( strlen(s) + 9 + strlen(new_str) + 1 ); |
|
|
|
buffer = TMALLOC(char, strlen(s) + 9 + strlen(new_str) + 1); |
|
|
|
sprintf( buffer, "%s params: %s", s, new_str ); |
|
|
|
|
|
|
|
tfree(s); tfree(new_str); |
|
|
|
@ -1922,7 +1922,7 @@ inp_remove_ws( char *s ) |
|
|
|
char *buffer, *curr; |
|
|
|
bool is_expression = FALSE; |
|
|
|
|
|
|
|
big_buff = (char*) tmalloc( strlen(s) + 1 ); |
|
|
|
big_buff = TMALLOC(char, strlen(s) + 1); |
|
|
|
curr = s; |
|
|
|
|
|
|
|
while ( *curr != '\0' ) { |
|
|
|
@ -2213,7 +2213,7 @@ inp_fix_inst_line( char *inst_line, |
|
|
|
} |
|
|
|
|
|
|
|
for ( i = 0; i < num_subckt_params; i++ ) { |
|
|
|
new_line = (char*) tmalloc( strlen( curr_line ) + strlen( subckt_param_values[i] ) + 2 ); |
|
|
|
new_line = TMALLOC(char, strlen( curr_line ) + strlen( subckt_param_values[i] ) + 2); |
|
|
|
sprintf( new_line, "%s %s", curr_line, subckt_param_values[i] ); |
|
|
|
|
|
|
|
tfree( curr_line ); |
|
|
|
@ -2259,11 +2259,11 @@ inp_fix_subckt_multiplier( struct line *subckt_card, |
|
|
|
num_subckt_params = num_subckt_params + 1; |
|
|
|
|
|
|
|
if ( !strstr( subckt_card->li_line, "params:" ) ) { |
|
|
|
new_str = (char*) tmalloc( strlen( subckt_card->li_line ) + 13 ); |
|
|
|
new_str = TMALLOC(char, strlen( subckt_card->li_line ) + 13); |
|
|
|
sprintf( new_str, "%s params: m=1", subckt_card->li_line ); |
|
|
|
subckt_w_params[num_subckt_w_params++] = get_subckt_model_name( subckt_card->li_line ); |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen( subckt_card->li_line ) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen( subckt_card->li_line ) + 5); |
|
|
|
sprintf( new_str, "%s m=1", subckt_card->li_line ); |
|
|
|
} |
|
|
|
|
|
|
|
@ -2276,7 +2276,7 @@ inp_fix_subckt_multiplier( struct line *subckt_card, |
|
|
|
/* no 'm' for B line or comment line */ |
|
|
|
if ((*(card->li_line) == '*') || (*(card->li_line) == 'b')) |
|
|
|
continue; |
|
|
|
new_str = (char*) tmalloc( strlen( card->li_line ) + 7 ); |
|
|
|
new_str = TMALLOC(char, strlen( card->li_line ) + 7); |
|
|
|
sprintf( new_str, "%s m={m}", card->li_line ); |
|
|
|
|
|
|
|
tfree( card->li_line ); |
|
|
|
@ -2552,20 +2552,20 @@ inp_do_macro_param_replace( int fcn_number, char *params[] ) |
|
|
|
|
|
|
|
if ( curr_str != NULL ) { |
|
|
|
if ( str_has_arith_char( params[i] ) ) { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 3 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 3); |
|
|
|
sprintf( new_str, "%s%s(%s)", curr_str, curr_ptr, params[i] ); |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 1 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_str) + strlen(curr_ptr) + strlen(params[i]) + 1); |
|
|
|
sprintf( new_str, "%s%s%s", curr_str, curr_ptr, params[i] ); |
|
|
|
} |
|
|
|
|
|
|
|
tfree( curr_str ); |
|
|
|
} else { |
|
|
|
if ( str_has_arith_char( params[i] ) ) { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_ptr) + strlen(params[i]) + 3 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_ptr) + strlen(params[i]) + 3); |
|
|
|
sprintf( new_str, "%s(%s)", curr_ptr, params[i] ); |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_ptr) + strlen(params[i]) + 1 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_ptr) + strlen(params[i]) + 1); |
|
|
|
sprintf( new_str, "%s%s", curr_ptr, params[i] ); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -2578,7 +2578,7 @@ inp_do_macro_param_replace( int fcn_number, char *params[] ) |
|
|
|
if ( curr_str == NULL ) { |
|
|
|
curr_str = curr_ptr; |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_str) + strlen(curr_ptr) + 1 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_str) + strlen(curr_ptr) + 1); |
|
|
|
sprintf( new_str, "%s%s", curr_str, curr_ptr ); |
|
|
|
tfree(curr_str); |
|
|
|
curr_str = new_str; |
|
|
|
@ -2669,11 +2669,11 @@ inp_expand_macro_in_str( char *str ) |
|
|
|
keep = *fcn_name; |
|
|
|
*fcn_name = '\0'; |
|
|
|
if ( curr_str == NULL ) { |
|
|
|
new_str = (char*) tmalloc( strlen(str) + strlen(macro_str) + strlen(close_paren_ptr+1) + 3 ); |
|
|
|
new_str = TMALLOC(char, strlen(str) + strlen(macro_str) + strlen(close_paren_ptr + 1) + 3); |
|
|
|
sprintf( new_str, "%s(%s)", str, macro_str ); |
|
|
|
curr_str = new_str; |
|
|
|
} else { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_str) + strlen(str) + strlen(macro_str) + strlen(close_paren_ptr+1) + 3 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_str) + strlen(str) + strlen(macro_str) + strlen(close_paren_ptr + 1) + 3); |
|
|
|
sprintf( new_str, "%s%s(%s)", curr_str, str, macro_str ); |
|
|
|
tfree(curr_str); |
|
|
|
curr_str = new_str; |
|
|
|
@ -2696,7 +2696,7 @@ inp_expand_macro_in_str( char *str ) |
|
|
|
} |
|
|
|
else { |
|
|
|
if ( str != NULL ) { |
|
|
|
new_str = (char*) tmalloc( strlen(curr_str) + strlen(str) + 1 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_str) + strlen(str) + 1); |
|
|
|
sprintf( new_str, "%s%s", curr_str, str ); |
|
|
|
tfree(curr_str); |
|
|
|
curr_str = new_str; |
|
|
|
@ -2831,7 +2831,7 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
end_of_str++; |
|
|
|
n++; |
|
|
|
} |
|
|
|
vec_str = (char*) tmalloc(n); /* string xx yyy from vector [xx yyy] */ |
|
|
|
vec_str = TMALLOC(char, n); /* string xx yyy from vector [xx yyy] */ |
|
|
|
*vec_str = '\0'; |
|
|
|
strncat(vec_str, beg_of_str + 1, n - 1); |
|
|
|
|
|
|
|
@ -2842,7 +2842,7 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
if (!natok) break; |
|
|
|
wl = alloc(struct wordlist); |
|
|
|
|
|
|
|
buffer = (char*) tmalloc(strlen(natok) + 4); |
|
|
|
buffer = TMALLOC(char, strlen(natok) + 4); |
|
|
|
if ( isdigit(*natok) || *natok == '{' || *natok == '.' || |
|
|
|
*natok == '"' || ( *natok == '-' && isdigit(*(natok+1)) ) || |
|
|
|
ciprefix("true", natok) || ciprefix("false", natok) || |
|
|
|
@ -2886,7 +2886,7 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
wl_free(nwl); |
|
|
|
/* insert new vector into actual line */ |
|
|
|
*equal_ptr = '\0'; |
|
|
|
new_str = (char*) tmalloc( strlen(c->li_line) + strlen(newvec) + strlen(end_of_str+1) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen(c->li_line) + strlen(newvec) + strlen(end_of_str + 1) + 5); |
|
|
|
sprintf( new_str, "%s=[%s] %s", c->li_line, newvec, end_of_str+1 ); |
|
|
|
tfree(newvec); |
|
|
|
|
|
|
|
@ -2903,7 +2903,7 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
end_of_str++; |
|
|
|
n++; |
|
|
|
} |
|
|
|
vec_str = (char*) tmalloc(n); /* string xx yyy from vector [xx yyy] */ |
|
|
|
vec_str = TMALLOC(char, n); /* string xx yyy from vector [xx yyy] */ |
|
|
|
*vec_str = '\0'; |
|
|
|
strncat(vec_str, beg_of_str + 1, n - 1); |
|
|
|
|
|
|
|
@ -2914,7 +2914,7 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
if (!natok) break; |
|
|
|
wl = alloc(struct wordlist); |
|
|
|
|
|
|
|
buffer = (char*) tmalloc(strlen(natok) + 4); |
|
|
|
buffer = TMALLOC(char, strlen(natok) + 4); |
|
|
|
if ( isdigit(*natok) || *natok == '{' || *natok == '.' || |
|
|
|
*natok == '"' || ( *natok == '-' && isdigit(*(natok+1)) ) || |
|
|
|
ciprefix("true", natok) || ciprefix("false", natok)) { |
|
|
|
@ -2936,7 +2936,7 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
wl_free(nwl); |
|
|
|
/* insert new complex value into actual line */ |
|
|
|
*equal_ptr = '\0'; |
|
|
|
new_str = (char*) tmalloc( strlen(c->li_line) + strlen(newvec) + strlen(end_of_str+1) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen(c->li_line) + strlen(newvec) + strlen(end_of_str + 1) + 5); |
|
|
|
sprintf( new_str, "%s=<%s> %s", c->li_line, newvec, end_of_str+1 ); |
|
|
|
tfree(newvec); |
|
|
|
|
|
|
|
@ -2956,13 +2956,13 @@ inp_fix_param_values( struct line *deck ) |
|
|
|
*equal_ptr = '\0'; |
|
|
|
|
|
|
|
if ( *end_of_str == '\0' ) { |
|
|
|
new_str = (char*) tmalloc( strlen(c->li_line) + strlen(beg_of_str) + 4 ); |
|
|
|
new_str = TMALLOC(char, strlen(c->li_line) + strlen(beg_of_str) + 4); |
|
|
|
sprintf( new_str, "%s={%s}", c->li_line, beg_of_str ); |
|
|
|
|
|
|
|
} else { |
|
|
|
*end_of_str = '\0'; |
|
|
|
|
|
|
|
new_str = (char*) tmalloc( strlen(c->li_line) + strlen(beg_of_str) + strlen(end_of_str+1) + 5 ); |
|
|
|
new_str = TMALLOC(char, strlen(c->li_line) + strlen(beg_of_str) + strlen(end_of_str + 1) + 5); |
|
|
|
sprintf( new_str, "%s={%s} %s", c->li_line, beg_of_str, end_of_str+1 ); |
|
|
|
} |
|
|
|
old_str = c->li_line; |
|
|
|
@ -3168,22 +3168,22 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca |
|
|
|
num_params = 0; /* This is just to keep the code in row 2907ff. */ |
|
|
|
|
|
|
|
// dynamic memory allocation |
|
|
|
level = (int *) tmalloc(arr_size*sizeof(int)); |
|
|
|
param_skip = (int *) tmalloc(arr_size*sizeof(int)); |
|
|
|
param_names = (char **) tmalloc(arr_size*sizeof(char*)); |
|
|
|
param_strs = (char **) tmalloc(arr_size*sizeof(char*)); |
|
|
|
level = TMALLOC(int, arr_size); |
|
|
|
param_skip = TMALLOC(int, arr_size); |
|
|
|
param_names = TMALLOC(char *, arr_size); |
|
|
|
param_strs = TMALLOC(char *, arr_size); |
|
|
|
|
|
|
|
/* array[row][column] -> depends_on[array_size][100] */ |
|
|
|
/* rows */ |
|
|
|
depends_on = (char ***) tmalloc(sizeof(char **) * arr_size); |
|
|
|
depends_on = TMALLOC(char **, arr_size); |
|
|
|
/* columns */ |
|
|
|
for (i = 0; i < arr_size; i++) |
|
|
|
{ |
|
|
|
depends_on[i] = (char **) tmalloc(sizeof(char *) * 100); |
|
|
|
depends_on[i] = TMALLOC(char *, 100); |
|
|
|
} |
|
|
|
|
|
|
|
ptr_array = (struct line **) tmalloc(arr_size*sizeof(struct line *)); |
|
|
|
ptr_array_ordered = (struct line **) tmalloc(arr_size*sizeof(struct line *)); |
|
|
|
ptr_array = TMALLOC(struct line *, arr_size); |
|
|
|
ptr_array_ordered = TMALLOC(struct line *, arr_size); |
|
|
|
|
|
|
|
ptr = start_card; |
|
|
|
while ( ptr != NULL ) |
|
|
|
@ -3298,12 +3298,12 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca |
|
|
|
*str_ptr = '\0'; |
|
|
|
if ( *end != '\0' ) |
|
|
|
{ |
|
|
|
new_str = (char*) tmalloc( strlen(curr_line) + strlen(param_names[i]) + strlen(end) + 3 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_line) + strlen(param_names[i]) + strlen(end) + 3); |
|
|
|
sprintf( new_str, "%s{%s}%s", curr_line, param_names[i], end ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
new_str = (char*) tmalloc( strlen(curr_line) + strlen(param_names[i]) + 3 ); |
|
|
|
new_str = TMALLOC(char, strlen(curr_line) + strlen(param_names[i]) + 3); |
|
|
|
sprintf( new_str, "%s{%s}", curr_line, param_names[i] ); |
|
|
|
} |
|
|
|
str_ptr = new_str + strlen(curr_line) + strlen(param_names[i]); |
|
|
|
@ -3377,7 +3377,7 @@ inp_add_params_to_subckt( struct line *subckt_card ) |
|
|
|
while ( isspace(*param_ptr) ) param_ptr++; |
|
|
|
|
|
|
|
if ( !strstr( subckt_line, "params:" ) ) { |
|
|
|
new_line = (char*) tmalloc( strlen(subckt_line) + strlen("params: ") + strlen(param_ptr) + 2 ); |
|
|
|
new_line = TMALLOC(char, strlen(subckt_line) + strlen("params: ") + strlen(param_ptr) + 2); |
|
|
|
sprintf( new_line, "%s params: %s", subckt_line, param_ptr ); |
|
|
|
|
|
|
|
subckt_name = subckt_card->li_line; |
|
|
|
@ -3390,7 +3390,7 @@ inp_add_params_to_subckt( struct line *subckt_card ) |
|
|
|
subckt_w_params[num_subckt_w_params++] = strdup(subckt_name); |
|
|
|
*end_ptr = keep; |
|
|
|
} else { |
|
|
|
new_line = (char*) tmalloc( strlen(subckt_line) + strlen(param_ptr) + 2 ); |
|
|
|
new_line = TMALLOC(char, strlen(subckt_line) + strlen(param_ptr) + 2); |
|
|
|
sprintf( new_line, "%s %s", subckt_line, param_ptr ); |
|
|
|
} |
|
|
|
|
|
|
|
@ -3515,7 +3515,7 @@ inp_split_multi_param_lines( struct line *deck, int line_num ) |
|
|
|
beg_param++; |
|
|
|
keep = *end_param; |
|
|
|
*end_param = '\0'; |
|
|
|
new_line = (char*) tmalloc( strlen(".param ") + strlen(beg_param) + 1 ); |
|
|
|
new_line = TMALLOC(char, strlen(".param ") + strlen(beg_param) + 1); |
|
|
|
sprintf( new_line, ".param %s", beg_param ); |
|
|
|
array[counter++] = new_line; |
|
|
|
*end_param = keep; |
|
|
|
@ -3674,13 +3674,13 @@ static void inp_compat(struct line *deck) |
|
|
|
// Exxx n1 n2 int1 0 1 |
|
|
|
xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) |
|
|
|
+ 20 - 4*2 + 1; |
|
|
|
ckt_array[0] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[0] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[0], "%s %s %s %s_int1 0 1", |
|
|
|
title_tok, node1, node2, title_tok); |
|
|
|
// BExxx int1 0 V = {equation} |
|
|
|
xlen = 2*strlen(title_tok) + strlen(str_ptr) |
|
|
|
+ 20 - 3*2 + 1; |
|
|
|
ckt_array[1] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[1] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[1], "b%s %s_int1 0 v = %s", |
|
|
|
title_tok, title_tok, str_ptr); |
|
|
|
|
|
|
|
@ -3744,13 +3744,13 @@ static void inp_compat(struct line *deck) |
|
|
|
// Gxxx n1 n2 int1 0 1 |
|
|
|
xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) |
|
|
|
+ 20 - 4*2 + 1; |
|
|
|
ckt_array[0] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[0] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[0], "%s %s %s %s_int1 0 1", |
|
|
|
title_tok, node1, node2, title_tok); |
|
|
|
// BGxxx int1 0 V = {equation} |
|
|
|
xlen = 2*strlen(title_tok) + strlen(str_ptr) |
|
|
|
+ 20 - 3*2 + 1; |
|
|
|
ckt_array[1] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[1] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[1], "b%s %s_int1 0 v = %s", |
|
|
|
title_tok, title_tok, str_ptr); |
|
|
|
|
|
|
|
@ -3806,7 +3806,7 @@ static void inp_compat(struct line *deck) |
|
|
|
xlen = strlen(title_tok) + strlen(node1) + strlen(node2) + |
|
|
|
strlen(node1) + strlen(node2) + strlen(str_ptr) + |
|
|
|
28 - 6*2 + 1; |
|
|
|
xline = (char*)tmalloc(xlen); |
|
|
|
xline = TMALLOC(char, xlen); |
|
|
|
sprintf(xline, "b%s %s %s i = v(%s, %s)/(%s)", title_tok, node1, node2, |
|
|
|
node1, node2, str_ptr); |
|
|
|
new_line = alloc(struct line); |
|
|
|
@ -3847,18 +3847,18 @@ static void inp_compat(struct line *deck) |
|
|
|
// Exxx n-aux 0 n1 n2 1 |
|
|
|
xlen = 2*strlen(title_tok) + strlen(node1) + strlen(node2) |
|
|
|
+ 21 - 4*2 + 1; |
|
|
|
ckt_array[0] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[0] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[0], "e%s %s_int2 0 %s %s 1", |
|
|
|
title_tok, title_tok, node1, node2); |
|
|
|
// Cxxx n-aux 0 1 |
|
|
|
xlen = 2*strlen(title_tok) |
|
|
|
+ 15 - 2*2 + 1; |
|
|
|
ckt_array[1] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[1] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[1], "c%s %s_int2 0 1", title_tok, title_tok); |
|
|
|
// Bxxx n2 n1 I = i(Exxx) * equation |
|
|
|
xlen = 2*strlen(title_tok) + strlen(node2) + strlen(node1) |
|
|
|
+ strlen(str_ptr) + 27 - 2*5 + 1; |
|
|
|
ckt_array[2] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[2] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[2], "b%s %s %s i = i(e%s) * (%s)", |
|
|
|
title_tok, node2, node1, title_tok, str_ptr); |
|
|
|
|
|
|
|
@ -3916,18 +3916,18 @@ static void inp_compat(struct line *deck) |
|
|
|
// Fxxx n-aux 0 Bxxx 1 |
|
|
|
xlen = 3*strlen(title_tok) |
|
|
|
+ 20 - 3*2 + 1; |
|
|
|
ckt_array[0] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[0] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[0], "f%s %s_int2 0 b%s -1", |
|
|
|
title_tok, title_tok, title_tok); |
|
|
|
// Lxxx n-aux 0 1 |
|
|
|
xlen = 2*strlen(title_tok) |
|
|
|
+ 15 - 2*2 + 1; |
|
|
|
ckt_array[1] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[1] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[1], "l%s %s_int2 0 1", title_tok, title_tok); |
|
|
|
// Bxxx n1 n2 V = v(n-aux) * equation |
|
|
|
xlen = 2*strlen(title_tok) + strlen(node2) + strlen(node1) |
|
|
|
+ strlen(str_ptr) + 31 - 2*5 + 1; |
|
|
|
ckt_array[2] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[2] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[2], "b%s %s %s v = v(%s_int2) * (%s)", |
|
|
|
title_tok, node1, node2, title_tok, str_ptr); |
|
|
|
|
|
|
|
@ -4033,17 +4033,17 @@ static void inp_compat(struct line *deck) |
|
|
|
exp_ptr = copy_substring(beg_ptr, end_ptr-2); |
|
|
|
cut_line = str_ptr; |
|
|
|
// generate node |
|
|
|
out_ptr = (char*)tmalloc(6); |
|
|
|
out_ptr = TMALLOC(char, 6); |
|
|
|
sprintf(out_ptr, "pa_%02d", pai); |
|
|
|
// Bout_ptr out_ptr 0 V = v(expr_ptr) |
|
|
|
xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; |
|
|
|
ckt_array[pai] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[pai] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[pai], "b%s %s 0 v = %s", |
|
|
|
out_ptr, out_ptr, exp_ptr); |
|
|
|
ckt_array[++pai] = NULL; |
|
|
|
// length of the replacement V(out_ptr) |
|
|
|
xlen = strlen(out_ptr) + 4; |
|
|
|
del_ptr = copy_ptr = (char*)tmalloc(xlen); |
|
|
|
del_ptr = copy_ptr = TMALLOC(char, xlen); |
|
|
|
sprintf(copy_ptr, "v(%s)", out_ptr); |
|
|
|
// length of the replacement part in original line |
|
|
|
xlen = strlen(exp_ptr) + 7; |
|
|
|
@ -4064,17 +4064,17 @@ static void inp_compat(struct line *deck) |
|
|
|
end_ptr++; |
|
|
|
exp_ptr = copy_substring(beg_ptr, end_ptr-3); |
|
|
|
// generate node |
|
|
|
out_ptr = (char*)tmalloc(6); |
|
|
|
out_ptr = TMALLOC(char, 6); |
|
|
|
sprintf(out_ptr, "pa_%02d", pai); |
|
|
|
// Bout_ptr out_ptr 0 V = v(expr_ptr) |
|
|
|
xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; |
|
|
|
ckt_array[pai] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[pai] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[pai], "b%s %s 0 v = %s", |
|
|
|
out_ptr, out_ptr, exp_ptr); |
|
|
|
ckt_array[++pai] = NULL; |
|
|
|
// length of the replacement V(out_ptr) |
|
|
|
xlen = strlen(out_ptr) + 4; |
|
|
|
del_ptr = copy_ptr = (char*)tmalloc(xlen); |
|
|
|
del_ptr = copy_ptr = TMALLOC(char, xlen); |
|
|
|
sprintf(copy_ptr, "v(%s)", out_ptr); |
|
|
|
// length of the replacement part in original line |
|
|
|
xlen = strlen(exp_ptr) + 9; |
|
|
|
@ -4150,17 +4150,17 @@ static void inp_compat(struct line *deck) |
|
|
|
exp_ptr = copy_substring(beg_ptr, end_ptr-2); |
|
|
|
cut_line = str_ptr; |
|
|
|
// generate node |
|
|
|
out_ptr = (char*)tmalloc(6); |
|
|
|
out_ptr = TMALLOC(char, 6); |
|
|
|
sprintf(out_ptr, "pa_%02d", pai); |
|
|
|
// Bout_ptr out_ptr 0 V = v(expr_ptr) |
|
|
|
xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; |
|
|
|
ckt_array[pai] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[pai] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[pai], "b%s %s 0 v = %s", |
|
|
|
out_ptr, out_ptr, exp_ptr); |
|
|
|
ckt_array[++pai] = NULL; |
|
|
|
// length of the replacement V(out_ptr) |
|
|
|
xlen = strlen(out_ptr) + 1; |
|
|
|
del_ptr = copy_ptr = (char*)tmalloc(xlen); |
|
|
|
del_ptr = copy_ptr = TMALLOC(char, xlen); |
|
|
|
sprintf(copy_ptr, "%s", out_ptr); |
|
|
|
// length of the replacement part in original line |
|
|
|
xlen = strlen(exp_ptr) + 7; |
|
|
|
@ -4189,13 +4189,13 @@ static void inp_compat(struct line *deck) |
|
|
|
exp_ptr = copy_substring(beg_ptr, end_ptr-3); |
|
|
|
// Bout_ptr out_ptr 0 V = v(expr_ptr) |
|
|
|
xlen = 2*strlen(out_ptr) + strlen(exp_ptr )+ 15 - 2*3 + 1; |
|
|
|
ckt_array[pai] = (char*)tmalloc(xlen); |
|
|
|
ckt_array[pai] = TMALLOC(char, xlen); |
|
|
|
sprintf(ckt_array[pai], "b%s %s 0 v = %s", |
|
|
|
out_ptr, out_ptr, exp_ptr); |
|
|
|
ckt_array[++pai] = NULL; |
|
|
|
// length of the replacement V(out_ptr) |
|
|
|
xlen = strlen(out_ptr) + 1; |
|
|
|
del_ptr = copy_ptr = (char*)tmalloc(xlen); |
|
|
|
del_ptr = copy_ptr = TMALLOC(char, xlen); |
|
|
|
sprintf(copy_ptr, "%s", out_ptr); |
|
|
|
// length of the replacement part in original line |
|
|
|
xlen = strlen(out_ptr) + strlen(exp_ptr) + 10; |
|
|
|
@ -4464,7 +4464,7 @@ static void inp_bsource_compat(struct line *deck) |
|
|
|
/* {} around all other tokens */ |
|
|
|
else { |
|
|
|
xlen = strlen(buf); |
|
|
|
tmp_char = (char*) tmalloc(xlen + 3); |
|
|
|
tmp_char = TMALLOC(char, xlen + 3); |
|
|
|
sprintf(tmp_char, "{%s}", buf); |
|
|
|
cwl->wl_word = tmp_char; |
|
|
|
} |
|
|
|
@ -4475,7 +4475,7 @@ static void inp_bsource_compat(struct line *deck) |
|
|
|
{ |
|
|
|
/* allow 100p, 5MEG etc. */ |
|
|
|
dvalue = INPevaluate(&str_ptr, &error1, 2); |
|
|
|
cvalue = (char*) tmalloc(19); |
|
|
|
cvalue = TMALLOC(char, 19); |
|
|
|
sprintf(cvalue,"%18.10e", dvalue); |
|
|
|
/* unary -, change sign */ |
|
|
|
if (ustate == 2) { |
|
|
|
@ -4510,7 +4510,7 @@ static void inp_bsource_compat(struct line *deck) |
|
|
|
/* cut the tmp_char after the equal sign */ |
|
|
|
*(equal_ptr + 1) = '\0'; |
|
|
|
xlen = strlen(tmp_char) + strlen(new_str) + 2; |
|
|
|
final_str = (char*) tmalloc(xlen); |
|
|
|
final_str = TMALLOC(char, xlen); |
|
|
|
sprintf(final_str, "%s %s", tmp_char, new_str); |
|
|
|
|
|
|
|
new_line = alloc(struct line); |
|
|
|
|