mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 15:48:30 +00:00
Update zygisk API to avoid mem leak
This commit is contained in:
parent
b696dae808
commit
97731a519a
@ -346,12 +346,13 @@ struct api_table {
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void entry_impl(api_table *table, JNIEnv *env) {
|
void entry_impl(api_table *table, JNIEnv *env) {
|
||||||
ModuleBase *module = new T();
|
static Api api;
|
||||||
if (!table->registerModule(table, new module_abi(module)))
|
api.tbl = table;
|
||||||
return;
|
static T module;
|
||||||
auto api = new Api();
|
ModuleBase *m = &module;
|
||||||
api->tbl = table;
|
static module_abi abi(m);
|
||||||
module->onLoad(api, env);
|
if (!table->registerModule(table, &abi)) return;
|
||||||
|
m->onLoad(&api, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
@ -385,10 +386,10 @@ inline bool Api::pltHookCommit() {
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
[[gnu::visibility("default")]] [[gnu::used]]
|
[[gnu::visibility("default"), maybe_unused]]
|
||||||
void zygisk_module_entry(zygisk::internal::api_table *, JNIEnv *);
|
void zygisk_module_entry(zygisk::internal::api_table *, JNIEnv *);
|
||||||
|
|
||||||
[[gnu::visibility("default")]] [[gnu::used]]
|
[[gnu::visibility("default"), maybe_unused]]
|
||||||
void zygisk_companion_entry(int);
|
void zygisk_companion_entry(int);
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user