diff options
author | Mark D. Roth <roth@google.com> | 2018-12-12 15:13:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 15:13:46 -0800 |
commit | 5e492721de246124d8b4cb97404a75c03711c140 (patch) | |
tree | 5a6f3a9092fb3bf0fc2273e26cb12c61a1314934 | |
parent | a310778ba0dee9b9c633872c93f20c0c8a6efe36 (diff) | |
parent | 1334f8d2009eba9cf9a00bb2469e514a43cd5f22 (diff) |
Merge pull request #17482 from markdroth/remove_memory_alignment_hack
Revert alignment hack in New<> and Delete<>.
-rw-r--r-- | src/core/lib/gprpp/memory.h | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index e90bedcd9b..b4b63ae771 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -40,15 +40,10 @@ namespace grpc_core { -// The alignment of memory returned by gpr_malloc(). -constexpr size_t kAlignmentForDefaultAllocationInBytes = 8; - // Alternative to new, since we cannot use it (for fear of libstdc++) template <typename T, typename... Args> inline T* New(Args&&... args) { - void* p = alignof(T) > kAlignmentForDefaultAllocationInBytes - ? gpr_malloc_aligned(sizeof(T), alignof(T)) - : gpr_malloc(sizeof(T)); + void* p = gpr_malloc(sizeof(T)); return new (p) T(std::forward<Args>(args)...); } @@ -57,11 +52,7 @@ template <typename T> inline void Delete(T* p) { if (p == nullptr) return; p->~T(); - if (alignof(T) > kAlignmentForDefaultAllocationInBytes) { - gpr_free_aligned(p); - } else { - gpr_free(p); - } + gpr_free(p); } template <typename T> |