aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/network_benchmarks
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-03-26 01:33:34 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-03-26 01:33:34 +0100
commit7c9a154803c0293a8c0b51bbec65dc00a950989e (patch)
tree86c1ae0a49af8c8e828644f0fb36c701531e276d /test/core/network_benchmarks
parentf3d76384351039266e250aacf97c90d5b0c07dca (diff)
Sanitize mallocs and frees.
Diffstat (limited to 'test/core/network_benchmarks')
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.c
index 7ed3372d5d..8179ba3b4d 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.c
+++ b/test/core/network_benchmarks/low_level_ping_pong.c
@@ -265,19 +265,19 @@ static int epoll_setup(thread_args *args) {
#endif
static void server_thread(thread_args *args) {
- char *buf = malloc(args->msg_size);
+ char *buf = gpr_malloc(args->msg_size);
if (args->setup(args) < 0) {
gpr_log(GPR_ERROR, "Setup failed");
}
for (;;) {
if (args->read_bytes(args, buf) < 0) {
gpr_log(GPR_ERROR, "Server read failed");
- free(buf);
+ gpr_free(buf);
return;
}
if (args->write_bytes(args, buf) < 0) {
gpr_log(GPR_ERROR, "Server write failed");
- free(buf);
+ gpr_free(buf);
return;
}
}
@@ -304,7 +304,8 @@ static double now(void) {
}
static void client_thread(thread_args *args) {
- char *buf = calloc(args->msg_size, sizeof(char));
+ char *buf = gpr_malloc(args->msg_size * sizeof(char));
+ memset(buf, 0, args->msg_size * sizeof(char));
gpr_histogram *histogram = gpr_histogram_create(0.01, 60e9);
double start_time;
double end_time;
@@ -333,7 +334,7 @@ static void client_thread(thread_args *args) {
}
print_histogram(histogram);
error:
- free(buf);
+ gpr_free(buf);
gpr_histogram_destroy(histogram);
}
@@ -596,8 +597,8 @@ static int run_all_benchmarks(size_t msg_size) {
test_strategy *strategy = &test_strategies[i];
size_t j;
for (j = 0; j < GPR_ARRAY_SIZE(socket_types); ++j) {
- thread_args *client_args = malloc(sizeof(thread_args));
- thread_args *server_args = malloc(sizeof(thread_args));
+ thread_args *client_args = gpr_malloc(sizeof(thread_args));
+ thread_args *server_args = gpr_malloc(sizeof(thread_args));
char *socket_type = socket_types[j];
client_args->read_bytes = strategy->read_strategy;
@@ -620,8 +621,8 @@ static int run_all_benchmarks(size_t msg_size) {
}
int main(int argc, char **argv) {
- thread_args *client_args = malloc(sizeof(thread_args));
- thread_args *server_args = malloc(sizeof(thread_args));
+ thread_args *client_args = gpr_malloc(sizeof(thread_args));
+ thread_args *server_args = gpr_malloc(sizeof(thread_args));
int msg_size = -1;
char *read_strategy = NULL;
char *socket_type = NULL;