From 5c58431646f05637d801c671a5f55a11903b37a5 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 6 Oct 2016 17:08:57 +0200 Subject: Coding style - set all pointers to NULL initially and after free --- src/gensvm_gridsearch.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/gensvm_gridsearch.c') diff --git a/src/gensvm_gridsearch.c b/src/gensvm_gridsearch.c index deee033..50b0020 100644 --- a/src/gensvm_gridsearch.c +++ b/src/gensvm_gridsearch.c @@ -37,7 +37,7 @@ void gensvm_fill_queue(struct GenGrid *grid, struct GenQueue *queue, { long i, j, k; long N, cnt = 0; - struct GenTask *task; + struct GenTask *task = NULL; queue->i = 0; N = grid->Np; @@ -203,7 +203,7 @@ double prctile(double *values, long N, double p) struct GenQueue *create_top_queue(struct GenQueue *q) { long i, k, N = 0; - double boundary, *perf; + double boundary, *perf = NULL; struct GenQueue *nq = Malloc(struct GenQueue, 1); // find the 95th percentile of performance @@ -271,10 +271,16 @@ struct GenQueue *create_top_queue(struct GenQueue *q) */ void consistency_repeats(struct GenQueue *q, long repeats, TrainType traintype) { - long i, f, r, N, *cv_idx; - double p, pi, pr, pt, *time, *std, *mean, *perf; - struct GenQueue *nq; - struct GenData **train_folds, **test_folds; + bool breakout; + long i, f, r, N, *cv_idx = NULL; + double p, pi, pr, pt, + *time = NULL, + *std = NULL, + *mean = NULL, + *perf = NULL; + struct GenQueue *nq = NULL; + struct GenData **train_folds = NULL, + **test_folds = NULL; struct GenModel *model = gensvm_init_model(); struct GenTask *task = NULL; clock_t loop_s, loop_e; @@ -338,7 +344,10 @@ void consistency_repeats(struct GenQueue *q, long repeats, TrainType traintype) gensvm_free_data(test_folds[f]); } free(train_folds); + train_folds = NULL; + free(test_folds); + test_folds = NULL; } for (r=0; r