aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/support/cpu_posix.cc
diff options
context:
space:
mode:
authorGravatar kwasimensah <kmensah@google.com>2017-11-01 13:26:00 -0400
committerGravatar GitHub <noreply@github.com>2017-11-01 13:26:00 -0400
commit4b02f3b2b6bf0f186a293e44753c30492584aad0 (patch)
tree918a1aeb1cdcd86d1961a4e12cdd1349b363e11c /src/core/lib/support/cpu_posix.cc
parent62e6b1c444916da1c1e725bb5e5952488b1692ca (diff)
Updated to use gpr_free and gpr_malloc
Diffstat (limited to 'src/core/lib/support/cpu_posix.cc')
-rw-r--r--src/core/lib/support/cpu_posix.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/lib/support/cpu_posix.cc b/src/core/lib/support/cpu_posix.cc
index c32ca4659c..2be66ef54e 100644
--- a/src/core/lib/support/cpu_posix.cc
+++ b/src/core/lib/support/cpu_posix.cc
@@ -27,6 +27,7 @@
#include <atomic>
+#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -56,7 +57,7 @@ unsigned gpr_cpu_current_cpu(void) {
static auto DeleteValue = [](void *value_ptr) {
unsigned int *value = static_cast<unsigned int *>(value_ptr);
if (value) {
- delete value;
+ gpr_free(value);
}
};
static pthread_key_t thread_id_key;
@@ -69,7 +70,8 @@ unsigned gpr_cpu_current_cpu(void) {
unsigned int *thread_id =
static_cast<unsigned int *>(pthread_getspecific(thread_id_key));
if (thread_id == nullptr) {
- thread_id = new unsigned int(thread_counter++);
+ thread_id = static_cast<unsigned int *>(gpr_malloc(sizeof(unsigned int)));
+ *thread_id = thread_counter++;
pthread_setspecific(thread_id_key, thread_id);
}