X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fgenerator.cc;h=1f40daedbc6fd21a1b70fac8c6433d1c892d5ded;hb=1d0993d84fd87ef620f60380745914bac3e77d34;hp=b2ba67caef9ad91370476e4469f59198eccca678;hpb=ad5cb8f903869065c72bb18bf98af6909189a5a9;p=awesomized%2Flibmemcached diff --git a/clients/generator.cc b/clients/generator.cc index b2ba67ca..1f40daed 100644 --- a/clients/generator.cc +++ b/clients/generator.cc @@ -20,7 +20,9 @@ #include #include -#include "generator.h" +#include "clients/generator.h" + +#define KEY_BYTES 20 /* Use this for string generation */ static const char ALPHANUMERICS[]= @@ -33,12 +35,14 @@ static size_t get_alpha_num(void) return (size_t)random() % ALPHANUMERICS_SIZE; } -static void get_random_string(char *buffer, size_t size) +void get_random_string(char *buffer, size_t size) { char *buffer_ptr= buffer; while (--size) + { *buffer_ptr++= ALPHANUMERICS[get_alpha_num()]; + } *buffer_ptr++= ALPHANUMERICS[get_alpha_num()]; } @@ -73,13 +77,13 @@ pairs_st *pairs_generate(uint64_t number_of, size_t value_length) for (uint64_t x= 0; x < number_of; x++) { - pairs[x].key= (char *)calloc(100, sizeof(char)); + pairs[x].key= (char *)calloc(KEY_BYTES, sizeof(char)); if (pairs[x].key == NULL) goto error; - get_random_string(pairs[x].key, 100); - pairs[x].key_length= 100; + get_random_string(pairs[x].key, KEY_BYTES); + pairs[x].key_length= KEY_BYTES; if (value_length) {