From: Date: Thu, 14 May 2009 05:37:09 +0000 (-0700) Subject: Adding an assert, plus a conversion of malloc to calloc X-Git-Tag: 0.29-2~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=729a6b6ffb3773a0553162b78d6cb84117e6aef5;p=awesomized%2Flibmemcached Adding an assert, plus a conversion of malloc to calloc --- diff --git a/clients/generator.c b/clients/generator.c index 8000910e..091b2808 100644 --- a/clients/generator.c +++ b/clients/generator.c @@ -44,22 +44,20 @@ pairs_st *pairs_generate(uint64_t number_of, size_t value_length) unsigned int x; pairs_st *pairs; - pairs= (pairs_st*)malloc(sizeof(pairs_st) * (number_of+1)); + pairs= (pairs_st*)calloc(number_of + 1, sizeof(pairs_st)); if (!pairs) goto error; - memset(pairs, 0, sizeof(pairs_st) * (number_of+1)); - for (x= 0; x < number_of; x++) { - pairs[x].key= (char *)malloc(sizeof(char) * 100); + pairs[x].key= (char *)calloc(100, sizeof(char)); if (!pairs[x].key) goto error; get_random_string(pairs[x].key, 100); pairs[x].key_length= 100; - pairs[x].value= (char *)malloc(sizeof(char) * value_length); + pairs[x].value= (char *)calloc(value_length, sizeof(char)); if (!pairs[x].value) goto error; get_random_string(pairs[x].value, value_length); diff --git a/clients/memslap.c b/clients/memslap.c index 509204eb..0baff1df 100644 --- a/clients/memslap.c +++ b/clients/memslap.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -371,6 +372,7 @@ void *run_task(void *p) switch (context->test) { case SET_TEST: + assert(context->execute_pairs); execute_set(memc, context->execute_pairs, context->execute_number); break; case GET_TEST: