Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
fix: remove _set_allocator.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroKaku committed Nov 19, 2022
1 parent 47a71ad commit b0e7656
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 59 deletions.
1 change: 0 additions & 1 deletion msvc/ucxxrt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@
<ClCompile Include="..\src\ucrt\heap\kfree.cpp" />
<ClCompile Include="..\src\ucrt\heap\malloc.cpp" />
<ClCompile Include="..\src\ucrt\heap\kmalloc.cpp" />
<ClCompile Include="..\src\ucrt\heap\moverride.cpp" />
<ClCompile Include="..\src\ucrt\heap\msize.cpp" />
<ClCompile Include="..\src\ucrt\heap\new_handler.cpp" />
<ClCompile Include="..\src\ucrt\heap\new_mode.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions msvc/ucxxrt.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,6 @@
<ClCompile Include="..\src\crt\vcruntime\new_km.cpp">
<Filter>ucxxrt\crt\vcruntime</Filter>
</ClCompile>
<ClCompile Include="..\src\ucrt\heap\moverride.cpp">
<Filter>ucxxrt\ucrt\heap</Filter>
</ClCompile>
<ClCompile Include="..\src\ucrt\heap\stdalloc.cpp">
<Filter>ucxxrt\ucrt\heap</Filter>
</ClCompile>
Expand Down
7 changes: 4 additions & 3 deletions src/crt/vcruntime/internal_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ _CRT_BEGIN_C_HEADER
extern ULONG __ucxxrt_tag;
extern IMAGE_DOS_HEADER __ImageBase;

extern volatile _malloc_t __override_malloc;
extern volatile _free_t __override_free;
extern volatile _msize_t __override_msize;


//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Expand Down Expand Up @@ -252,6 +249,10 @@ extern "C++"
//
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

_CRT_HYBRIDPATCHABLE __declspec(noinline) _CRTRESTRICT void* __cdecl std_malloc(size_t const size);
_CRT_HYBRIDPATCHABLE __declspec(noinline) void __cdecl std_free(void* const block);
_CRT_HYBRIDPATCHABLE __declspec(noinline) size_t __cdecl std_msize(void* const block);

// When building for vcruntime*.dll, we are not a part of the UCRT or OS so we
// should use the public allocation functions exported by the UCRT.
#define _calloc_crt calloc
Expand Down
2 changes: 0 additions & 2 deletions src/crt/vcruntime/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ extern "C" void __cdecl __scrt_initialize_memory()
{
// Nx
ExInitializeDriverRuntime(DrvRtPoolNxOptIn);

_set_allocator(nullptr, nullptr, nullptr);
}

extern "C" bool __cdecl __scrt_initialize_crt()
Expand Down
2 changes: 1 addition & 1 deletion src/ucrt/heap/free.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
// with either other function or vice versa.
extern "C" _CRT_HYBRIDPATCHABLE __declspec(noinline) void __cdecl free(void* const block)
{
return __override_free(block);
return std_free(block);
}
2 changes: 1 addition & 1 deletion src/ucrt/heap/malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" _CRT_HYBRIDPATCHABLE __declspec(noinline) _CRTRESTRICT void* __cdecl

for (;;)
{
void* const block = __override_malloc(size);
void* const block = std_malloc(size);
if (block)
return block;

Expand Down
39 changes: 0 additions & 39 deletions src/ucrt/heap/moverride.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/ucrt/heap/msize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
// with either other function or vice versa.
extern "C" _CRT_HYBRIDPATCHABLE __declspec(noinline) size_t __cdecl _msize(void* const block)
{
return __override_msize(block);
return std_msize(block);
}
2 changes: 1 addition & 1 deletion src/ucrt/heap/stdalloc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* PROJECT: Universal C++ RunTime (UCXXRT)
* FILE: stdalloc.cpp
* DATA: 2022/06/17
* DATA: 2022/11/17
*
* PURPOSE: Universal C++ RunTime
*
Expand Down
7 changes: 0 additions & 7 deletions src/ucxxrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ namespace ucxxrt
#endif


typedef void* (__cdecl* _malloc_t)(size_t const size);
typedef void (__cdecl* _free_t )(void* const block);
typedef size_t(__cdecl* _msize_t )(void* const block);

EXTERN_C void __cdecl _set_allocator(_malloc_t _malloc, _free_t _free, _msize_t _msize);


#if _MSC_VER >= 1200
#pragma warning(pop)
#endif
2 changes: 2 additions & 0 deletions src/ucxxrt.inl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
#include <cstdint>

#include "ucxxrt.h"
#include "kext/kmalloc.h"
#include "kext/knew.h"

#if _MSC_VER >= 1200
#pragma warning(pop)
Expand Down

0 comments on commit b0e7656

Please sign in to comment.