feat(libSceFreeType): implement FT_Done_Library and FT_Reference_Library #10606
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10606"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:24:18Z.
What
Adds
FT_Done_LibraryandFT_Reference_Libraryto libSceFreeType, following the bundled FreeType 2.13.3 (ftobjs.c). The guest library wrapper now carries a reference count that mirrors the native one:FT_Reference_Libraryraises both, andFT_Done_Librarylowers both and releases the wrapper together with the native library on the last reference.FT_Done_FreeTypeis unchanged: as natively, it drops one reference throughFT_Done_Libraryand then discards the memory manager whatever the count (ftinit.c), so a library that still has references is not usable afterwards and the guest wrapper is released at once. Like the native call,FT_Done_Librarydoes not free the memory manager thatFT_Init_FreeTypecreated.FT_New_Libraryis not included because it takes guest memory callbacks. Console signatures and errors are unverified; the debt entries say so.Commits: for each function in turn (
FT_Done_Library, thenFT_Reference_Library), the implementation, its test and its debt entry.Tested
Linux x86-64, GCC, full CMake build (Ninja, Release).
guest_freetype_library_referencescompares each call with the native one: dropping the only reference with open faces, a null library, and three extra references released one at a time with a face opened and closed between each step on both libraries. It also runs the existingguest_freetypesuite, which still passes. While building the test I found that nativeFT_Done_FreeTypefrees the memory manager even when references remain, so the test pairsFT_Reference_LibrarywithFT_Done_Library. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran the tests with that check disabled in a local, uncommitted edit; both exit 0. Windows was not run.tools/check_conventions.pyandgit diff --checkpass. No title or GPU involved.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:46:10Z.
Review: COMMENTED
Checked against main
c9b75825f3and FreeType 2.13.3 (42608f77)src/base/ftobjs.candsrc/base/ftinit.c:1XCz6Gk0Lt4/qAPXM5DN62Qmatch the names, and the branch still merges cleanly into current main. The two wrappers mirror native refcounting correctly, and on the last reference nativeFT_Done_Faceruns the existing finalizer hooks before the wrapper is deleted, in the same order as the existingFT_Done_FreeTypepath.FT_Reference_Librarydebt line (and the PR text) says nativeFT_Done_FreeTypeignores the count and releases the library at once. In 2.13.3 it callsFT_Done_Library, which only decrements while references remain (ftobjs.c:5567-5568), and then frees the memory manager (ftinit.c). So natively the library and its faces stay allocated (leaked, with a freed memory manager), not released. Main'sFT_Done_FreeType_nid_postfix(Export.cpp:107-111) still deletes the wrapper and all itsGuestFaceobjects in that case, so afterFT_Reference_LibrarythenFT_Done_FreeType, a guest face pointer is already freed on our side while natively it's only leaked. It's an edge case natively too, but could the debt wording be corrected, and possiblyFT_Done_FreeTypethrow whenreferences > 1rather than silently diverging?Export.cppline asFT_MODULE_Hhere, so one of them will need a trivial rebase.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Pull request closed