diff options
-rw-r--r-- | lf_fifo_test.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lf_fifo_test.c b/lf_fifo_test.c index 0b41aec..7d6a165 100644 --- a/lf_fifo_test.c +++ b/lf_fifo_test.c @@ -94,8 +94,12 @@ void* aggressive_push( void* param ) params = (thread_params_t*)param; fifo = params->fifo; - nodes = params->nodes = malloc( sizeof(node_t)*params->n); - if (nodes==NULL) _failure("nodes malloc failure"); + nodes = params->nodes; + if (nodes==NULL) + { + nodes = params->nodes = malloc( sizeof(node_t)*params->n); + if (nodes==NULL) _failure("nodes malloc failure"); + } for(i=0; i<params->n; i++) { @@ -186,7 +190,7 @@ static void run_aggressive_push_pop(int threads_n, int nodes_n) for(i=0; i<threads_n; i++) { j += params[i].n; - free(params[i].nodes); + if (params[i].nodes) free(params[i].nodes); } _check((j==(threads_n*nodes_n)),"poped nodes count failure"); |