From 820aca66839d755eefa2a5eb107095051576a6ff Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 27 Aug 2010 18:01:47 +0200 Subject: [PATCH] SWZ: replace free with swzFree --- matlab/swz/c-code/sbvar/var/forecast.c | 18 +++++------ .../DWCcode/histogram/dw_histogram.c | 30 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/matlab/swz/c-code/sbvar/var/forecast.c b/matlab/swz/c-code/sbvar/var/forecast.c index d98baebd0..b1b9f6ddd 100644 --- a/matlab/swz/c-code/sbvar/var/forecast.c +++ b/matlab/swz/c-code/sbvar/var/forecast.c @@ -119,7 +119,7 @@ int forecast_percentile(FILE *f_out, TVector percentiles, int draws, FILE *poste ERROR_EXIT: FreeMatrixHistogram(histogram); FreeMatrix(forecast); - free(S); + swzFree(S); FreeVector(initial); FreeVector(prob); FreeVector(init_prob); @@ -229,7 +229,7 @@ int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws, ERROR_EXIT: FreeMatrixHistogram(histogram); FreeMatrix(forecast); - free(S); + swzFree(S); FreeVector(initial); FreeVector(prob); FreeVector(init_prob); @@ -362,9 +362,9 @@ int main(int nargs, char **args) Read_VAR_Parameters((FILE*)NULL,parm,head,model); p=(T_VAR_Parameters*)(model->theta); - free(spec); - free(head); - free(parm); + swzFree(spec); + swzFree(head); + swzFree(parm); //============================= Compute forecasts ============================= @@ -374,7 +374,7 @@ int main(int nargs, char **args) /* fmt="forecasts_mean_%s.prn"; */ /* sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag); */ /* f_out=fopen(out_filename,"wt"); */ - /* free(out_filename); */ + /* swzFree(out_filename); */ /* printf("Constructing mean forecast\n"); */ /* if (F=dw_state_space_mean_unconditional_forecast((TVector*)NULL,h,statespace->nobs,model)) */ /* for (i=0; i < h; i++) */ @@ -452,7 +452,7 @@ int main(int nargs, char **args) fmt="forecasts_percentiles_regime_%d_%s.prn"; sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 3),fmt,s,tag); f_out=fopen(out_filename,"wt"); - free(out_filename); + swzFree(out_filename); printf("Constructing percentiles for forecasts - regime %d\n",s); forecast_percentile_regime(f_out,percentiles,draws,posterior_file,s,p->nobs,horizon,model); fclose(f_out); @@ -463,7 +463,7 @@ int main(int nargs, char **args) fmt="forecasts_percentiles_regime_%d_%s.prn"; sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 3),fmt,s,tag); f_out=fopen(out_filename,"wt"); - free(out_filename); + swzFree(out_filename); printf("Constructing percentiles for forecasts - regime %d\n",s); forecast_percentile_regime(f_out,percentiles,draws,posterior_file,s,p->nobs,horizon,model); fclose(f_out); @@ -473,7 +473,7 @@ int main(int nargs, char **args) fmt="forecasts_percentiles_%s.prn"; sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag); f_out=fopen(out_filename,"wt"); - free(out_filename); + swzFree(out_filename); printf("Constructing percentiles for forecasts - %d draws of shocks/regimes per posterior value\n",draws); forecast_percentile(f_out,percentiles,draws,posterior_file,p->nobs,horizon,model); fclose(f_out); diff --git a/matlab/swz/c-code/utilities/DWCcode/histogram/dw_histogram.c b/matlab/swz/c-code/utilities/DWCcode/histogram/dw_histogram.c index 70241c927..627a18b21 100644 --- a/matlab/swz/c-code/utilities/DWCcode/histogram/dw_histogram.c +++ b/matlab/swz/c-code/utilities/DWCcode/histogram/dw_histogram.c @@ -81,17 +81,17 @@ void FreeMatrixHistogram(TMatrixHistogram *h) int i, j; for (i=h->rows-1; i >= 0; i--) { - for (j=h->cols-1; j >= 0; j--) free(h->freq[i][j]); - free(h->freq[i]); + for (j=h->cols-1; j >= 0; j--) swzFree(h->freq[i][j]); + swzFree(h->freq[i]); } - free(h->freq); - for (i=h->rows-1; i >= 0; i--) free(h->low[i]); - free(h->low); - for (i=h->rows-1; i >= 0; i--) free(h->high[i]); - free(h->high); + swzFree(h->freq); + for (i=h->rows-1; i >= 0; i--) swzFree(h->low[i]); + swzFree(h->low); + for (i=h->rows-1; i >= 0; i--) swzFree(h->high[i]); + swzFree(h->high); FreeMatrix(h->Min); FreeMatrix(h->Max); - free(h); + swzFree(h); } void AddMatrixObservation(TMatrix X, TMatrixHistogram *h) @@ -226,13 +226,13 @@ void SetMaxMinVectorHistogram(TVector Min, TVector Max, TVectorHistogram *h) void FreeVectorHistogram(TVectorHistogram *h) { int i; - for (i=h->dim-1; i >= 0; i--) free(h->freq[i]); - free(h->freq); - free(h->low); - free(h->high); + for (i=h->dim-1; i >= 0; i--) swzFree(h->freq[i]); + swzFree(h->freq); + swzFree(h->low); + swzFree(h->high); FreeVector(h->Min); FreeVector(h->Max); - free(h); + swzFree(h); } void AddVectorObservation(TVector x, TVectorHistogram *h) @@ -355,8 +355,8 @@ void SetMaxMinScalarHistogram(PRECISION Min, PRECISION Max, TScalarHistogram *h) void FreeScalarHistogram(TScalarHistogram *h) { - free(h->freq); - free(h); + swzFree(h->freq); + swzFree(h); } void AddScalarObservation(PRECISION x, TScalarHistogram *h)