格式化代码, 修复 Clang 不能编译, 修复 il2cpp_thread_attach 可能导致的崩溃, 修复 il2cpp_type_get_name 导致的内存泄漏 #46
+3,276
−2,959
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
根据 Unity 2022.3.59f1 的源代码,
il2cpp_type_get_name
的定义如下:其中
il2cpp_alloc
实际上(默认)调用malloc
, 也就是在堆上分配新内存, 而 C++std::string
对于从(const) char *
构造的行为是复制指针所指向的字符串的内容, 但不会负责释放该指针, 所以我们需要调用il2cpp_free
显式释放返回值, 避免内存泄漏.