X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fgenerator.c;h=091b280876e18ad1d12757a7d5b45eca90c072b6;hb=633d8e0a860fd45374e4f1f3c284e198ee0cd82c;hp=c9750231104dcfd1552d5f79330fda0bdac075e8;hpb=2b312deb8b7b3f662b492f94a13e673723387724;p=awesomized%2Flibmemcached diff --git a/clients/generator.c b/clients/generator.c index c9750231..091b2808 100644 --- a/clients/generator.c +++ b/clients/generator.c @@ -1,3 +1,5 @@ +#include "libmemcached/common.h" + #include #include #include @@ -42,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);