mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
Publish portable Darling runtime patch snapshot and testing tools
This commit is contained in:
commit
a96cdc62b1
186 files changed
+45822
No files matched your search
@@ -0,0 +1,22 @@
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <new>
|
||||
#include <objc/runtime.h>
|
||||
static bool ready;
|
||||
static unsigned deletes;
|
||||
void* operator new(std::size_t n) { return std::malloc(n ? n : 1); }
|
||||
void* operator new[](std::size_t n) { return ::operator new(n); }
|
||||
void operator delete(void* p) noexcept {
|
||||
if (p && !ready) { std::fputs("FAIL application delete used before main\n",stderr); std::abort(); }
|
||||
if(p) ++deletes;
|
||||
std::free(p);
|
||||
}
|
||||
void operator delete[](void* p) noexcept { ::operator delete(p); }
|
||||
int main() {
|
||||
ready=true;
|
||||
if(objc_getClassList(nullptr,0)<=0) return 1;
|
||||
void* p=::operator new(64); ::operator delete(p);
|
||||
if(deletes!=1) return 2;
|
||||
std::puts("PASS Objective-C startup uses private allocation; app delete remains active");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user