mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-17 17:36:44 +00:00
ro: reduce memory usage by excising (unused) std::malloc
This commit is contained in:
parent
170034aed3
commit
5191f0e305
6 changed files with 47 additions and 7 deletions
|
@ -122,6 +122,8 @@ $(OFILES) : $(GCH_FILES)
|
|||
|
||||
$(OFILES_SRC) : $(HFILES_BIN)
|
||||
|
||||
ams_environment_weak.o: CXXFLAGS += -fno-lto
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%_bin.h %.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
@ -26,4 +26,7 @@ namespace ams {
|
|||
void InitializeForBoot();
|
||||
void SetInitialRebootPayload(const void *src, size_t src_size);
|
||||
|
||||
void *Malloc(size_t size);
|
||||
void Free(void *ptr);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams {
|
||||
|
||||
WEAK_SYMBOL void *Malloc(size_t size) {
|
||||
return std::malloc(size);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void Free(void *ptr) {
|
||||
return std::free(ptr);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,16 +23,16 @@ namespace ams::fs {
|
|||
|
||||
void *DefaultAllocate(size_t size) {
|
||||
g_used_default_allocator = true;
|
||||
return std::malloc(size);
|
||||
return ams::Malloc(size);
|
||||
}
|
||||
|
||||
void DefaultDeallocate(void *ptr, size_t size) {
|
||||
std::free(ptr);
|
||||
ams::Free(ptr);
|
||||
}
|
||||
|
||||
os::Mutex g_lock(false);
|
||||
AllocateFunction g_allocate_func = DefaultAllocate;
|
||||
DeallocateFunction g_deallocate_func = DefaultDeallocate;
|
||||
constinit os::SdkMutex g_lock;
|
||||
constinit AllocateFunction g_allocate_func = DefaultAllocate;
|
||||
constinit DeallocateFunction g_deallocate_func = DefaultDeallocate;
|
||||
|
||||
constexpr size_t RequiredAlignment = alignof(u64);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace ams::os::impl {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ReplyAndReceiveN(s32 *out_index, s32 num, Handle arr[], s32 array_size, s64 ns, Handle reply_target) {
|
||||
Result WaitableManagerHorizonImpl::ReplyAndReceiveN(s32 *out_index, s32 num, Handle arr[], s32 array_size, s64 ns, Handle reply_target) {
|
||||
/* NOTE: Nintendo does not initialize this value, which seems like it can cause incorrect behavior. */
|
||||
s32 index = WaitableManagerImpl::WaitInvalid;
|
||||
static_assert(WaitableManagerImpl::WaitInvalid != -1);
|
||||
|
|
|
@ -170,8 +170,15 @@ void __appExit(void) {
|
|||
setsysExit();
|
||||
}
|
||||
|
||||
namespace {
|
||||
namespace ams {
|
||||
|
||||
void *Malloc(size_t size) {
|
||||
AMS_ABORT("ams::Malloc was called");
|
||||
}
|
||||
|
||||
void Free(void *ptr) {
|
||||
AMS_ABORT("ams::Free was called");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue