projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Adding an assert, plus a conversion of malloc to calloc
[awesomized/libmemcached]
/
clients
/
generator.c
diff --git
a/clients/generator.c
b/clients/generator.c
index 793157ef52666e611b4a8fd3a4bb7732876679bd..091b280876e18ad1d12757a7d5b45eca90c072b6 100644
(file)
--- a/
clients/generator.c
+++ b/
clients/generator.c
@@
-1,5
+1,8
@@
+#include "libmemcached/common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include "generator.h"
#include <string.h>
#include "generator.h"
@@
-21,7
+24,7
@@
static void get_random_string(char *buffer, size_t size)
void pairs_free(pairs_st *pairs)
{
void pairs_free(pairs_st *pairs)
{
- u
nsigned in
t x;
+ u
int32_
t x;
if (!pairs)
return;
if (!pairs)
return;
@@
-36,27
+39,25
@@
void pairs_free(pairs_st *pairs)
free(pairs);
}
free(pairs);
}
-pairs_st *pairs_generate(u
nsigned long long
number_of, size_t value_length)
+pairs_st *pairs_generate(u
int64_t
number_of, size_t value_length)
{
unsigned int x;
pairs_st *pairs;
{
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;
if (!pairs)
goto error;
- memset(pairs, 0, sizeof(pairs_st) * (number_of+1));
-
for (x= 0; x < number_of; x++)
{
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;
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);
if (!pairs[x].value)
goto error;
get_random_string(pairs[x].value, value_length);