Skip to content

Commit 5b90468

Browse files
committed
MB-67589: Fix C4456 reported by MSVC...
Declaration of variable hides previous declaration Change-Id: I86c90ce6d6a0bce1d954d220db417cfb9433dff6 Reviewed-on: https://review.couchbase.org/c/platform/+/237036 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Pavlos Georgiou <pavlos.georgiou@couchbase.com>
1 parent 652b853 commit 5b90468

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,19 @@ if (UNIX)
344344
endif()
345345

346346
if (MEMORY_ALLOCATOR STREQUAL "jemalloc")
347-
LIST(APPEND PLATFORM_FILES src/je_arena_corelocal_tracker.cc)
348-
LIST(APPEND PLATFORM_FILES src/je_arena_simple_tracker.cc)
349-
LIST(APPEND PLATFORM_FILES src/je_arena_malloc.cc)
350-
LIST(APPEND PLATFORM_FILES src/je_arena_malloc_stats.cc)
351-
endif()
347+
LIST(APPEND PLATFORM_FILES src/je_arena_corelocal_tracker.cc)
348+
LIST(APPEND PLATFORM_FILES src/je_arena_simple_tracker.cc)
349+
LIST(APPEND PLATFORM_FILES src/je_arena_malloc.cc)
350+
LIST(APPEND PLATFORM_FILES src/je_arena_malloc_stats.cc)
351+
352+
# Exclude je_arena_simple_tracker.cc from unity builds as it
353+
# defines a static array which cause compiler warning when other
354+
# files in the same unity build also define variables with the same
355+
# name.
356+
set_source_files_properties(
357+
src/je_arena_corelocal_tracker.cc
358+
PROPERTIES SKIP_UNITY_BUILD_INCLUSION 1)
359+
endif ()
352360
# Always build the system_arena code for simpler concurrent development
353361
LIST(APPEND PLATFORM_FILES src/system_arena_malloc.cc)
354362

include/platform/memory_tracking_allocator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ class MemoryTrackingAllocator {
106106
return baseAllocator.allocate(n);
107107
}
108108

109-
void deallocate(value_type* p, std::size_t n) noexcept {
109+
void deallocate(value_type* ptr, std::size_t n) noexcept {
110110
*bytesAllocated -= n * sizeof(T);
111-
baseAllocator.deallocate(p, n);
111+
baseAllocator.deallocate(ptr, n);
112112
}
113113

114114
MemoryTrackingAllocator select_on_container_copy_construction() const {

tests/arena_malloc/arena_malloc_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ TEST_F(ArenaMalloc, DomainGuard) {
143143

144144
void *p1, *p2;
145145
{
146-
cb::UseArenaMallocSecondaryDomain domain;
146+
cb::UseArenaMallocSecondaryDomain secondary_domain;
147147
p1 = cb_malloc(4096);
148148
EXPECT_EQ(0,
149149
cb::ArenaMalloc::getPreciseAllocated(
@@ -173,7 +173,7 @@ TEST_F(ArenaMalloc, DomainGuard) {
173173
client, cb::MemoryDomain::Secondary));
174174

175175
{
176-
cb::UseArenaMallocSecondaryDomain domain;
176+
cb::UseArenaMallocSecondaryDomain secondary_domain;
177177
cb_free(p1);
178178
EXPECT_EQ(0,
179179
cb::ArenaMalloc::getPreciseAllocated(

0 commit comments

Comments
 (0)