aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2017-03-09 10:32:09 -0800
committerGravatar ncteisen <ncteisen@gmail.com>2017-03-09 10:54:07 -0800
commita3e5801e2ef90988074cd6c1b74fb7d876f09533 (patch)
tree9f249eeaaafa06c5b18ab65171d7a221cdd34dd5
parenta885d00a3843e13ed234f8a13c58a7ff9de4b397 (diff)
s/realloc/gpr_realloc to fix mem bug
-rw-r--r--src/core/lib/iomgr/error.c2
-rw-r--r--test/cpp/microbenchmarks/bm_error.cc2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.c
index 42c2f3e2dd..f0b7e01d49 100644
--- a/src/core/lib/iomgr/error.c
+++ b/src/core/lib/iomgr/error.c
@@ -210,7 +210,7 @@ static uint8_t get_placement(grpc_error **err, size_t size) {
uint8_t slots = (uint8_t)(size / sizeof(intptr_t));
if ((*err)->arena_size + slots > (*err)->arena_capacity) {
(*err)->arena_capacity = (uint8_t)(3 * (*err)->arena_capacity / 2);
- *err = realloc(
+ *err = gpr_realloc(
*err, sizeof(grpc_error) + (*err)->arena_capacity * sizeof(intptr_t));
}
uint8_t placement = (*err)->arena_size;
diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc
index 6331b24592..76f168b75b 100644
--- a/test/cpp/microbenchmarks/bm_error.cc
+++ b/test/cpp/microbenchmarks/bm_error.cc
@@ -72,12 +72,14 @@ static void BM_ErrorCreateAndSetStatus(benchmark::State& state) {
BENCHMARK(BM_ErrorCreateAndSetStatus);
static void BM_ErrorCreateAndSetIntAndStr(benchmark::State& state) {
+ TrackCounters track_counters;
while (state.KeepRunning()) {
GRPC_ERROR_UNREF(grpc_error_set_str(
grpc_error_set_int(GRPC_ERROR_CREATE("GOAWAY received"),
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)0),
GRPC_ERROR_STR_RAW_BYTES, "raw bytes"));
}
+ track_counters.Finish(state);
}
BENCHMARK(BM_ErrorCreateAndSetIntAndStr);