X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fgenerator.cc;h=1f40daedbc6fd21a1b70fac8c6433d1c892d5ded;hb=ecb8ed2090d2bc35c4ffe5febe1ba465d3e0be5d;hp=e41d9c58acecdf53f9a7a0ed90a4917f1ee62f23;hpb=8cf5f36e16ecaf6e1e7622a3a7cad81491602b0d;p=m6w6%2Flibmemcached diff --git a/clients/generator.cc b/clients/generator.cc index e41d9c58..1f40daed 100644 --- a/clients/generator.cc +++ b/clients/generator.cc @@ -10,7 +10,7 @@ * */ -#include +#include #include @@ -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) {