Resolution of merge conflicts with pre-master: txfree()->free() in code models.

This commit is contained in:
Jim Monte 2020-02-22 01:27:24 -05:00
parent 69c6fd72da
commit bc5fc3ff0f
13 changed files with 48 additions and 54 deletions

View File

@ -11,12 +11,6 @@ static void no_free(const void *p) {
} }
#endif #endif
/* Returns the version string for ngspice */
static const char *get_ngspice_version(void)
{
const char *buf = VERSION;
return buf;
} /* end of function get_ngspice_version */
/* Returns stdout, stdin, and stderr */ /* Returns stdout, stdin, and stderr */

View File

@ -227,7 +227,7 @@ void cm_filesource(ARGS) /* structure holding parms, inputs, outputs, etc.
else { else {
sprintf(p, "%s%s%s", lbuffer, DIR_PATHSEP, PARAM(file)); sprintf(p, "%s%s%s", lbuffer, DIR_PATHSEP, PARAM(file));
loc->state->fp = fopen(p, "r"); loc->state->fp = fopen(p, "r");
txfree(p); free(p);
} }
} }
if (!loc->state->fp) { if (!loc->state->fp) {
@ -260,12 +260,12 @@ void cm_filesource(ARGS) /* structure holding parms, inputs, outputs, etc.
while (*cp && isspace_c(*cp)) while (*cp && isspace_c(*cp))
++cp; ++cp;
if (*cp == '*' || *cp == '#' || *cp == ';') { if (*cp == '*' || *cp == '#' || *cp == ';') {
txfree(cpdel); free(cpdel);
continue; continue;
} }
t = strtod(cp, &cp2); t = strtod(cp, &cp2);
if (cp2 == cp) { if (cp2 == cp) {
txfree(cpdel); free(cpdel);
continue; continue;
} }
cp = cp2; cp = cp2;
@ -306,7 +306,7 @@ void cm_filesource(ARGS) /* structure holding parms, inputs, outputs, etc.
t += PARAM(amploffset[i]); t += PARAM(amploffset[i]);
loc->indata->datavec[count++] = t; loc->indata->datavec[count++] = t;
} }
txfree(cpdel); free(cpdel);
} }
loc->indata->maxoccupied = count; loc->indata->maxoccupied = count;
@ -381,25 +381,25 @@ static void cm_filesource_callback(ARGS, Mif_Callback_Reason_t reason)
if (loc->state->fp != (FILE *) NULL) { if (loc->state->fp != (FILE *) NULL) {
fclose(loc->state->fp); fclose(loc->state->fp);
} }
txfree(loc->state); free(loc->state);
} }
if (loc->amplinterval != (double *) NULL) { if (loc->amplinterval != (double *) NULL) {
txfree(loc->amplinterval); free(loc->amplinterval);
} }
if (loc->timeinterval != (double *) NULL) { if (loc->timeinterval != (double *) NULL) {
txfree(loc->timeinterval); free(loc->timeinterval);
} }
if (loc->indata) { if (loc->indata) {
if (loc->indata->datavec) { if (loc->indata->datavec) {
txfree(loc->indata->datavec); free(loc->indata->datavec);
} }
txfree(loc->indata); free(loc->indata);
} }
txfree(loc); free(loc);
STATIC_VAR(locdata) = NULL; STATIC_VAR(locdata) = NULL;
break; break;

View File

@ -572,9 +572,9 @@ static void cm_oneshot_callback(ARGS, Mif_Callback_Reason_t reason)
if (loc == (Local_Data_t *) NULL) { if (loc == (Local_Data_t *) NULL) {
break; break;
} }
txfree(loc->control); free(loc->control);
txfree(loc->pw); free(loc->pw);
txfree(loc); free(loc);
STATIC_VAR(locdata) = (Local_Data_t *) NULL; STATIC_VAR(locdata) = (Local_Data_t *) NULL;
break; break;
} }

View File

@ -231,17 +231,17 @@ cm_pwl_callback(ARGS, Mif_Callback_Reason_t reason)
case MIF_CB_DESTROY: { case MIF_CB_DESTROY: {
void *p = STATIC_VAR(last_x_value); void *p = STATIC_VAR(last_x_value);
if (p != NULL) { if (p != NULL) {
txfree(p); free(p);
} }
p = STATIC_VAR(x); p = STATIC_VAR(x);
if (p != NULL) { if (p != NULL) {
txfree(p); free(p);
} }
p = STATIC_VAR(y); p = STATIC_VAR(y);
if (p != NULL) { if (p != NULL) {
txfree(p); free(p);
} }
STATIC_VAR (last_x_value) = NULL; STATIC_VAR (last_x_value) = NULL;

View File

@ -620,22 +620,22 @@ void cm_s_xfer(ARGS) /* structure holding parms, inputs, outputs, etc. */
EXITPOINT: EXITPOINT:
/* free all allocated memory */ /* free all allocated memory */
if (old_integrator != (double **) NULL) { if (old_integrator != (double **) NULL) {
txfree(old_integrator); free(old_integrator);
} }
if (integrator != (double **) NULL) { if (integrator != (double **) NULL) {
txfree(integrator); free(integrator);
} }
if (den_coefficient != (double **) NULL) { if (den_coefficient != (double **) NULL) {
txfree(den_coefficient); free(den_coefficient);
} }
if (old_den_coefficient != (double **) NULL) { if (old_den_coefficient != (double **) NULL) {
txfree(old_den_coefficient); free(old_den_coefficient);
} }
if (num_coefficient != (double **) NULL) { if (num_coefficient != (double **) NULL) {
txfree(num_coefficient); free(num_coefficient);
} }
if (old_num_coefficient != (double **) NULL) { if (old_num_coefficient != (double **) NULL) {
txfree(old_num_coefficient); free(old_num_coefficient);
} }
} /* end of function cm_s_xfer */ } /* end of function cm_s_xfer */

View File

@ -407,7 +407,7 @@ static void cm_d_genlut_callback(ARGS, Mif_Callback_Reason_t reason)
case MIF_CB_DESTROY: { case MIF_CB_DESTROY: {
void * const p = STATIC_VAR(locdata); void * const p = STATIC_VAR(locdata);
if (p != NULL) { if (p != NULL) {
txfree(p); free(p);
} }
break; break;
} }

View File

@ -269,7 +269,7 @@ static void cm_d_lut_callback(ARGS, Mif_Callback_Reason_t reason)
case MIF_CB_DESTROY: { case MIF_CB_DESTROY: {
void * const p = STATIC_VAR(locdata); void * const p = STATIC_VAR(locdata);
if (p != NULL) { if (p != NULL) {
txfree(p); free(p);
} }
break; break;
} }

View File

@ -286,7 +286,7 @@ void cm_d_osc(ARGS)
y = (double *) calloc((size_t) freq_size, sizeof(double)); y = (double *) calloc((size_t) freq_size, sizeof(double));
if (!y) { if (!y) {
cm_message_send(d_osc_allocation_error); cm_message_send(d_osc_allocation_error);
txfree(x); free(x);
return; return;
} }
@ -394,8 +394,8 @@ void cm_d_osc(ARGS)
txfree(x); free(x);
txfree(y); free(y);
} }

View File

@ -183,7 +183,7 @@ static char *CNVgettok(char **s)
switch(**s) { switch(**s) {
case '\0': /* End of string found */ case '\0': /* End of string found */
txfree(buf); free(buf);
return (char *) NULL; return (char *) NULL;
default: /* Otherwise, we are dealing with a */ default: /* Otherwise, we are dealing with a */
@ -220,7 +220,7 @@ static char *CNVgettok(char **s)
return (char *) NULL; return (char *) NULL;
} }
strcpy(ret_str, buf); strcpy(ret_str, buf);
txfree(buf); free(buf);
return ret_str; return ret_str;
} }
@ -737,7 +737,7 @@ static int cm_read_source(FILE *source, Local_Data_t *loc)
while ( type != CNV_NO_TOK ) { while ( type != CNV_NO_TOK ) {
token = CNVget_token(&s, &type); token = CNVget_token(&s, &type);
if (token) if (token)
txfree(token); free(token);
j++; j++;
} }
num_tokens = j; num_tokens = j;
@ -813,7 +813,7 @@ static int cm_read_source(FILE *source, Local_Data_t *loc)
} }
} }
if (token) if (token)
txfree(token); free(token);
} }
i++; i++;
} }
@ -945,7 +945,7 @@ void cm_d_source(ARGS)
} }
sprintf(p, "%s%s%s", lbuffer, DIR_PATHSEP, PARAM(input_file)); sprintf(p, "%s%s%s", lbuffer, DIR_PATHSEP, PARAM(input_file));
source = fopen(p, "r"); source = fopen(p, "r");
txfree(p); free(p);
} }
if (!source) if (!source)
cm_message_printf("cannot open file %s", PARAM(input_file)); cm_message_printf("cannot open file %s", PARAM(input_file));
@ -1229,10 +1229,10 @@ static void free_local_data(Local_Data_t *loc)
int i; int i;
for (i = 0; i != n; ++i) { /* free individual allocs */ for (i = 0; i != n; ++i) { /* free individual allocs */
if (all_data[i] != (char *) NULL) { if (all_data[i] != (char *) NULL) {
txfree(all_data[i]); free(all_data[i]);
} }
} }
txfree(all_data); free(all_data);
} }
} }
@ -1240,11 +1240,11 @@ static void free_local_data(Local_Data_t *loc)
{ {
void * const p = loc->all_timepoints; void * const p = loc->all_timepoints;
if (p != NULL) { if (p != NULL) {
txfree(p); free(p);
} }
} }
txfree(loc); free(loc);
} /* end of function free_local_data */ } /* end of function free_local_data */

View File

@ -225,7 +225,7 @@ static char *CNVgettok(char **s)
switch(**s) { switch(**s) {
case '\0': /* End of string found */ case '\0': /* End of string found */
txfree(buf); free(buf);
return (char *) NULL; return (char *) NULL;
default: /* Otherwise, we are dealing with a */ default: /* Otherwise, we are dealing with a */
@ -262,7 +262,7 @@ static char *CNVgettok(char **s)
return (char *) NULL; return (char *) NULL;
} }
strcpy(ret_str, buf); strcpy(ret_str, buf);
txfree(buf); free(buf);
return ret_str; return ret_str;
} }
@ -2136,19 +2136,19 @@ static void free_state_fields(State_Table_t *p_state)
{ {
void *p; void *p;
if ((p = p_state->state) != NULL) { if ((p = p_state->state) != NULL) {
txfree(p); free(p);
p_state->state = (int *) NULL; p_state->state = (int *) NULL;
} }
if ((p = p_state->bits) != NULL) { if ((p = p_state->bits) != NULL) {
txfree(p); free(p);
p_state->bits = (short *) NULL; p_state->bits = (short *) NULL;
} }
if ((p = p_state->inputs) != NULL) { if ((p = p_state->inputs) != NULL) {
txfree(p); free(p);
p_state->inputs = (short *) NULL; p_state->inputs = (short *) NULL;
} }
if ((p = p_state->next_state) != NULL) { if ((p = p_state->next_state) != NULL) {
txfree(p); free(p);
p_state->next_state = (int *) NULL; p_state->next_state = (int *) NULL;
} }
} /* end of function free_state_fields */ } /* end of function free_state_fields */

View File

@ -75,7 +75,7 @@ cm_spice2poly_callback(ARGS, Mif_Callback_Reason_t reason)
case MIF_CB_DESTROY: { case MIF_CB_DESTROY: {
Mif_Inst_Var_Data_t *p = STATIC_VAR_INST(acgains); Mif_Inst_Var_Data_t *p = STATIC_VAR_INST(acgains);
if(p->element) { if(p->element) {
txfree(p->element); free(p->element);
p->element = NULL; p->element = NULL;
} }
break; break;
@ -234,13 +234,13 @@ void spice2poly (ARGS)
/* Free the allocated items and return */ /* Free the allocated items and return */
EXITPOINT: EXITPOINT:
if (in != (double *) NULL) { if (in != (double *) NULL) {
txfree(in); free(in);
} }
if (coef != (double *) NULL) { if (coef != (double *) NULL) {
txfree(coef); free(coef);
} }
if (exp != (int *) NULL) { if (exp != (int *) NULL) {
txfree(exp); free(exp);
} }
return; return;

View File

@ -94,7 +94,7 @@ static void cm_sidiode_callback(ARGS, Mif_Callback_Reason_t reason)
case MIF_CB_DESTROY: { case MIF_CB_DESTROY: {
Local_Data_t *loc = (Local_Data_t *) STATIC_VAR(locdata); Local_Data_t *loc = (Local_Data_t *) STATIC_VAR(locdata);
if (loc != (Local_Data_t *) NULL) { if (loc != (Local_Data_t *) NULL) {
txfree(loc); free(loc);
} }
break; break;
} }

View File

@ -372,7 +372,7 @@ static void cm_zener_callback(ARGS, Mif_Callback_Reason_t reason)
double * const p_prev_voltage = double * const p_prev_voltage =
(double *) STATIC_VAR(previous_voltage); (double *) STATIC_VAR(previous_voltage);
if (p_prev_voltage != (double *) NULL) { if (p_prev_voltage != (double *) NULL) {
txfree(p_prev_voltage); free(p_prev_voltage);
} }
break; break;
} }