Skip to content

Commit 7161fa3

Browse files
Use std placement new on non MSVC compilers
1 parent e26c81f commit 7161fa3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/Common/Memory/Allocator.h

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -448,14 +449,16 @@ void AssertValue(void * mem, T value, uint byteCount)
448449
#define NO_EXPORT(x) x
449450
#endif
450451

452+
#if defined(_MSC_VER) && !defined(__clang__)
453+
451454
// For the debugger extension, we don't need the placement news
452455
#ifndef __PLACEMENT_NEW_INLINE
453456
#define __PLACEMENT_NEW_INLINE
454457

455458
_Ret_notnull_
456459
NO_EXPORT(inline void *) __cdecl
457460
operator new(
458-
DECLSPEC_GUARD_OVERFLOW size_t byteSize,
461+
DECLSPEC_GUARD_OVERFLOW size_t byteSize,
459462
_In_ void * previousAllocation) throw()
460463
{
461464
return previousAllocation;
@@ -466,13 +469,21 @@ NO_EXPORT(inline void) __cdecl
466469
operator delete(
467470
void * allocationToFree, // Allocation to free
468471
void * previousAllocation // Previously allocated memory
469-
) throw()
472+
) throw()
470473
{
471474

472475
}
473476

474477
#endif
475478

479+
#else
480+
481+
// Use std inline placement new instead of custom
482+
// See PR #7009
483+
#include <new>
484+
485+
#endif
486+
476487
//----------------------------------------
477488
// throwing operator new overrides
478489
//----------------------------------------

0 commit comments

Comments
 (0)