diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-02-01 15:31:15 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-02-01 15:31:15 +0100 |
commit | 4f1ccf6e62c8f4576ee87ecb30c012f84fe08882 (patch) | |
tree | 1c41afb53fd7154e1af4bc5bab0b6d0c4ff84c4f | |
parent | 049947ab267a06fdb55003a9294d6c358f2ee7de (diff) | |
download | lock_free-4f1ccf6e62c8f4576ee87ecb30c012f84fe08882.zip lock_free-4f1ccf6e62c8f4576ee87ecb30c012f84fe08882.tar.gz |
take care of param.nodes
-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"); |