XSPICE sine source: memory leak removed (bug no. 3564166)
This commit is contained in:
parent
9f8c73d271
commit
10d97d222e
|
|
@ -16,7 +16,7 @@ v4 4 0 DC 1.0
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*** sine block ***
|
*** sine block ***
|
||||||
a1 1 10 sine1
|
a1 2 10 sine1
|
||||||
.model sine1 sine (cntl_array=[-1.0 0.0 10.0 20.0]
|
.model sine1 sine (cntl_array=[-1.0 0.0 10.0 20.0]
|
||||||
+ freq_array=[500 500 2000 2000]
|
+ freq_array=[500 500 2000 2000]
|
||||||
+ out_low=-1.0 out_high=1.0)
|
+ out_low=-1.0 out_high=1.0)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ AUTHORS
|
||||||
MODIFICATIONS
|
MODIFICATIONS
|
||||||
|
|
||||||
2 Oct 1991 Jeffrey P. Murray
|
2 Oct 1991 Jeffrey P. Murray
|
||||||
|
7 Sep 2012 Holger Vogt
|
||||||
|
|
||||||
|
|
||||||
SUMMARY
|
SUMMARY
|
||||||
|
|
@ -69,6 +70,14 @@ NON-STANDARD FEATURES
|
||||||
/*=== LOCAL VARIABLES & TYPEDEFS =======*/
|
/*=== LOCAL VARIABLES & TYPEDEFS =======*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
double *control; /* the storage array for the
|
||||||
|
control vector (cntl_array) */
|
||||||
|
|
||||||
|
double *freq; /* the storage array for the
|
||||||
|
frequency vector (freq_array) */
|
||||||
|
} Local_Data_t;
|
||||||
|
|
||||||
|
|
||||||
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
|
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
|
||||||
|
|
@ -88,6 +97,7 @@ AUTHORS
|
||||||
MODIFICATIONS
|
MODIFICATIONS
|
||||||
|
|
||||||
2 Oct 1991 Jeffrey P. Murray
|
2 Oct 1991 Jeffrey P. Murray
|
||||||
|
7 Sep 2012 Holger Vogt
|
||||||
|
|
||||||
SUMMARY
|
SUMMARY
|
||||||
|
|
||||||
|
|
@ -143,6 +153,9 @@ void cm_sine(ARGS) /* structure holding parms,
|
||||||
|
|
||||||
Mif_Complex_t ac_gain;
|
Mif_Complex_t ac_gain;
|
||||||
|
|
||||||
|
Local_Data_t *loc; /* Pointer to local static data, not to be included
|
||||||
|
in the state vector */
|
||||||
|
|
||||||
|
|
||||||
/**** Retrieve frequently used parameters... ****/
|
/**** Retrieve frequently used parameters... ****/
|
||||||
|
|
||||||
|
|
@ -161,7 +174,27 @@ void cm_sine(ARGS) /* structure holding parms,
|
||||||
|
|
||||||
cm_analog_alloc(INT1,sizeof(double));
|
cm_analog_alloc(INT1,sizeof(double));
|
||||||
|
|
||||||
|
|
||||||
|
/*** allocate static storage for *loc ***/
|
||||||
|
STATIC_VAR (locdata) = calloc (1 , sizeof ( Local_Data_t ));
|
||||||
|
loc = STATIC_VAR (locdata);
|
||||||
|
|
||||||
|
|
||||||
|
/* Allocate storage for breakpoint domain & freq. range values */
|
||||||
|
x = loc->control = (double *) calloc((size_t) cntl_size, sizeof(double));
|
||||||
|
if (!x) {
|
||||||
|
cm_message_send(allocation_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
y = loc->freq = (double *) calloc((size_t) freq_size, sizeof(double));
|
||||||
|
if (!y) {
|
||||||
|
cm_message_send(allocation_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ANALYSIS == MIF_DC){
|
if(ANALYSIS == MIF_DC){
|
||||||
|
|
||||||
OUTPUT(out) = (output_hi + output_low)/2;
|
OUTPUT(out) = (output_hi + output_low)/2;
|
||||||
|
|
@ -176,18 +209,9 @@ void cm_sine(ARGS) /* structure holding parms,
|
||||||
phase = (double *) cm_analog_get_ptr(INT1,0);
|
phase = (double *) cm_analog_get_ptr(INT1,0);
|
||||||
phase1 = (double *) cm_analog_get_ptr(INT1,1);
|
phase1 = (double *) cm_analog_get_ptr(INT1,1);
|
||||||
|
|
||||||
/* Allocate storage for breakpoint domain & freq. range values */
|
loc = STATIC_VAR (locdata);
|
||||||
x = (double *) calloc((size_t) cntl_size, sizeof(double));
|
x = loc->control;
|
||||||
if (!x) {
|
y = loc->freq;
|
||||||
cm_message_send(allocation_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
y = (double *) calloc((size_t) freq_size, sizeof(double));
|
|
||||||
if (!y) {
|
|
||||||
cm_message_send(allocation_error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Retrieve x and y values. */
|
/* Retrieve x and y values. */
|
||||||
for (i=0; i<cntl_size; i++) {
|
for (i=0; i<cntl_size; i++) {
|
||||||
|
|
|
||||||
|
|
@ -58,3 +58,9 @@ Vector: no no
|
||||||
Vector_Bounds: - -
|
Vector_Bounds: - -
|
||||||
Null_Allowed: yes yes
|
Null_Allowed: yes yes
|
||||||
|
|
||||||
|
|
||||||
|
STATIC_VAR_TABLE:
|
||||||
|
|
||||||
|
Static_Var_Name: locdata
|
||||||
|
Description: "local static data"
|
||||||
|
Data_Type: pointer
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue