X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fgenerator.c;h=80b398b251df3a73b0f476f0439a91553f8951b1;hb=0bbb14508a90f9af985efc198428e1560ab9b44a;hp=5bce0301ab6ae848f9315ea5b85c186210c8f30a;hpb=e1a4e5405f227e58347d775022dd38fa2595b20b;p=m6w6%2Flibmemcached diff --git a/clients/generator.c b/clients/generator.c index 5bce0301..80b398b2 100644 --- a/clients/generator.c +++ b/clients/generator.c @@ -1,4 +1,15 @@ -#include "libmemcached/common.h" +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: + * + */ + +#include "config.h" #include #include @@ -31,14 +42,15 @@ void pairs_free(pairs_st *pairs) { uint32_t x; - if (!pairs) + if (! pairs) return; /* We free until we hit the null pair we stores during creation */ for (x= 0; pairs[x].key; x++) { free(pairs[x].key); - free(pairs[x].value); + if (pairs[x].value) + free(pairs[x].value); } free(pairs); @@ -62,11 +74,19 @@ pairs_st *pairs_generate(uint64_t number_of, size_t value_length) get_random_string(pairs[x].key, 100); pairs[x].key_length= 100; - pairs[x].value= (char *)calloc(value_length, sizeof(char)); - if (!pairs[x].value) - goto error; - get_random_string(pairs[x].value, value_length); - pairs[x].value_length= value_length; + if (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); + pairs[x].value_length= value_length; + } + else + { + pairs[x].value= NULL; + pairs[x].value_length= 0; + } } return pairs;