FoxiGram/TMessagesProj/jni/voip/webrtc/base/process/memory_mac.mm
instant992 8e79f2ee9c FoxiGram: Telegram client with built-in Xray VLESS proxy
Based on Nekogram. Key additions:
- Rebrand to FoxiGram (app name, APK name, applicationId com.foxigram.app)
- Embedded Xray (VLESS+Reality) proxy client via JNI libxray.so
- Bundled hidden one-tap proxies (LTE + WiFi), read-only in UI
- Auto-restore proxy on restart, rebind to active network (LTE/WiFi)
- Server credentials externalized to git-ignored XrayServers.java (+ template)
- libxray Go source included; compiled .so, keystore, google-services.json ignored
2026-06-08 16:41:07 +04:00

49 lines
1.3 KiB
Text

// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/process/memory.h"
#include "base/allocator/allocator_interception_mac.h"
#include "base/allocator/allocator_shim.h"
#include "base/allocator/buildflags.h"
#include "build/build_config.h"
namespace base {
namespace {
void oom_killer_new() {
TerminateBecauseOutOfMemory(0);
}
} // namespace
void EnableTerminationOnHeapCorruption() {
#if !ARCH_CPU_64_BITS
DLOG(WARNING) << "EnableTerminationOnHeapCorruption only works on 64-bit";
#endif
}
bool UncheckedMalloc(size_t size, void** result) {
return allocator::UncheckedMallocMac(size, result);
}
bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
return allocator::UncheckedCallocMac(num_items, size, result);
}
void EnableTerminationOnOutOfMemory() {
// Step 1: Enable OOM killer on C++ failures.
std::set_new_handler(oom_killer_new);
// Step 2: Enable OOM killer on C-malloc failures for the default zone (if we
// have a shim).
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator::SetCallNewHandlerOnMallocFailure(true);
#endif
// Step 3: Enable OOM killer on all other malloc zones (or just "all" without
// "other" if shim is disabled).
allocator::InterceptAllocationsMac();
}
} // namespace base