feat(libSceFreeType): implement the legacy memory allocators #12004
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12004"
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 santhoshkumar-dev on 2026-10-27T16:37:28Z.
What
Add the legacy allocator family
FT_Alloc(Uw+BZJpflxk),FT_QAlloc(hz-J3hohXW8) andFT_Free(fHMsRluEMfI) to the physicallibSceFreeTypeadapter. The functions operate on the guestGuestMemoryReccallback record already used byFT_List_Finalize. An independently authored implementation follows the allocator family retained for old internals in FreeType 2.4.12 ftutil.c; the bundled 2.13.3 build no longer contains these names, so nothing is forwarded to it.The contract: allocation calls the guest
alloccallback for positive sizes only, clears the guest output when the callback returns null and reportsFT_Err_Out_Of_Memory,FT_Alloczeroes successful blocks whileFT_QAllocleaves callback contents intact, zero sizes produce a null block without error, negative sizes reportFT_Err_Invalid_Argumentwith a cleared output and no callback traffic, andFT_Freereleases through the guestfreecallback and nulls the output only when a block was freed. The negative-size rejection follows the reference implementation's explicitelse if ( size < 0 )check inft_mem_qalloc; the originally published head returned success there and is corrected in02896e7445. Null records or outputs make the allocating helpers throw; the reference implementation dereferences them.FT_Freeignores null memory records, output pointers and blocks; this divergence is explicitly recorded in debt and covered by the fixture. The names/NIDs are in the PS5 3.20 inventory and match the PS4 tables. Console ABI is unverified and recorded in debt.The matching OT inventory helper for
FT_QAllocis namedsceFreeTypeOtQAlloc_nid_no_patchand declared once inlibSceFreeTypeOt/include/MemoryAllocation.hpp, reachable through the Ot umbrella included by its export implementation; its no-parameter placeholder, explicit NID alias and throwing behavior remain. The Ol-provider stubs that currentmainadded forFT_AllocandFT_Freeare namedsceFreeTypeOlAlloc_nid_no_patchandsceFreeTypeOlFree_nid_no_patchand declared through the Ol umbrella header; their placeholders, explicit NID aliases and throwing behavior remain unchanged.Ordering: submitted head
6b7a1c9446fb4baa14531190e0b62e0e273ad116merges cleanly with mainaaccd0ba39b7d40fdbf19664575a7e567d8542f7. The allocator debt entry was moved below the existing reference-face entry to avoid #12680's new top-of-section insertion; the whole-branch combination with #12680 headcf9b7c6b392164b03f0479afbf109023513e1e41is clean. Registration remains outside the neighbouring arithmetic additions. #12373 is a stacked follow-up and depends on this PR; no other allocator implementation is claimed.Tested
Current submitted head
6b7a1c9446fb4baa14531190e0b62e0e273ad116adds review fixes to previously tested head74276c468329afcb9a6054e94a0195bebde8cd48. The 70/70 full-library/focused-CTest results below refer to that earlier head, including mainc02d287bd0; they were not rerun as a full product build for this header/debt/test-only follow-up.Fresh October 29 follow-up checks on Windows 11 / WinLibs GCC 15.2.0 and Ubuntu under WSL / GCC 13.3.0: the public-header audit passes (368 libraries, 13,054 exports); standalone allocator/Ot umbrella headers compile together and twice; the Ot export translation unit compiles on Windows and compiles on Linux. Each platform freshly compiles the production
MemoryAllocation.cppand revised in-tree fixture as isolated artifacts, then passes three runs in each normal and repository-NID-patched export mode. Windows links the existing product libc import library for its custom unwind support; this is not a fresh completelibsbuild. The new checks verify that freeing with a null record preserves a live block and contents, null output pointers make no callback, and the retained block can subsequently be freed normally. Conventions and whitespace pass.Windows 11 x64 / WinLibs GCC 15.2.0 r7 and local Ubuntu 24.04.1 x86-64 under WSL2 / GCC 13.3.0 / glibc 2.39: Ninja Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=OFF, in fresh build trees on each platform. On each platform the completelibstarget (including all packaged-NID.prxpatching) and selected test executables build, and 70/70 CTests pass: public-header audit, all 64 header compilation batches, both allocator export modes (unpatched names and packaged NIDsUw+BZJpflxk/hz-J3hohXW8/fHMsRluEMfI), charmap checks and the packaged-library loader.The fixture registers real guest callbacks in-process. Each mode verifies:
FT_Alloczeroing a callback-prepared dirty block;FT_QAllocpreserving the dirty pattern; theOut_Of_Memoryerror and cleared output when the callback returns null;FT_Freenulling the output after releasing, skipping null blocks and leaving the free counter unchanged; zero sizes producing null outputs without error or callback traffic; and negative sizes-1,-8andINT64_MINproducingInvalid_Argument(6) with a cleared output and zero callback traffic. A standalone regression outside the repository compiled the revised fixture against the previously published allocator implementation (fails its negative-size assertion, exit 1) and against this head (passes, exit 0) on Linux.No full application/test-suite, macOS, title or physical-console run is claimed.
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)