6a3b5103f084412e5b9d9dac077afa28c4f24a48
7 /* Use this for string generation */
8 static const char ALPHANUMERICS
[]=
9 "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
11 #define ALPHANUMERICS_SIZE (sizeof(ALPHANUMERICS)-1)
13 static void get_random_string(char *buffer
, size_t size
)
15 char *buffer_ptr
= buffer
;
18 *buffer_ptr
++= ALPHANUMERICS
[random() % ALPHANUMERICS_SIZE
];
19 *buffer_ptr
++= ALPHANUMERICS
[random() % ALPHANUMERICS_SIZE
];
22 void pairs_free(pairs_st
*pairs
)
29 /* We free until we hit the null pair we stores during creation */
30 for (x
= 0; pairs
[x
].key
; x
++)
39 pairs_st
*pairs_generate(uint64_t number_of
, size_t value_length
)
44 pairs
= (pairs_st
*)malloc(sizeof(pairs_st
) * (number_of
+1));
49 memset(pairs
, 0, sizeof(pairs_st
) * (number_of
+1));
51 for (x
= 0; x
< number_of
; x
++)
53 pairs
[x
].key
= (char *)malloc(sizeof(char) * 100);
56 get_random_string(pairs
[x
].key
, 100);
57 pairs
[x
].key_length
= 100;
59 pairs
[x
].value
= (char *)malloc(sizeof(char) * value_length
);
62 get_random_string(pairs
[x
].value
, value_length
);
63 pairs
[x
].value_length
= value_length
;
68 fprintf(stderr
, "Memory Allocation failure in pairs_generate.\n");