feat(libSceIcu): implement the uprv allocation and string duplication helpers #17629

Closed
JoanNugroho wants to merge 2 commits from upstream-pr/17629 into main
JoanNugroho commented 2026-11-09 04:53:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JoanNugroho on 2026-11-09T04:53:27Z.


Follows up #17231, which was closed automatically over the open PR limit and is reopened here from the same branch.

What

Implements uprv_malloc, uprv_realloc, uprv_strdup and uprv_strndup in libSceIcu. They were parameterless throwing placeholders in LegacyExports.cpp.

  • They follow ICU 78.1 cmemory.cpp and cstring.cpp, the revision the other libSceIcu entries already cite.
  • A zero-size request returns one shared non-null block. uprv_realloc treats that block as unallocated, and a resize of any other block to zero releases it and returns the shared block.
  • The callbacks stored by u_setMemoryFunctions are called with their context when set. Otherwise the blocks come from libc's guest heap, so a title releases them with free; the module exports no uprv_free.
  • uprv_strndup copies exactly n bytes, past a NUL, and a negative n duplicates the whole string. A null source throws where ICU faults.
  • The Memory function configuration debt entry no longer says that nothing calls the stored callbacks, and a new entry records what stays unverified.

Tested

  • Windows (WinLibs GCC 15.2.0 x86_64-ucrt-posix-seh r7, the CI toolchain): guest_icu_configuration passes, and all 26 icu tests pass (ctest -R icu).
  • Linux (Ubuntu 24.04, GCC 13.3), outside the project build: Configuration.cpp and the test compiled with libc's ApplicationHeap, ApplicationProcessParameters, GuestHeap, GuestArena and GuestAllocations sources pass under UBSan and at -O2.
  • core/libs/tests/test_public_headers.py --audit-only and tools/check_conventions.py pass.
  • No title or console run; the behaviour comes from the ICU sources above.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01QMWStysvjPgmgkKvPWyX1b

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5218917119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17629). Originally posted by [JoanNugroho](https://github.com/JoanNugroho) on 2026-11-09T04:53:27Z. --- Follows up #17231, which was closed automatically over the open PR limit and is reopened here from the same branch. ### What Implements `uprv_malloc`, `uprv_realloc`, `uprv_strdup` and `uprv_strndup` in libSceIcu. They were parameterless throwing placeholders in `LegacyExports.cpp`. - They follow ICU 78.1 [cmemory.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/cmemory.cpp) and [cstring.cpp](https://github.com/unicode-org/icu/blob/049e0d6a420629ac7db77256987d083a563287b5/icu4c/source/common/cstring.cpp), the revision the other libSceIcu entries already cite. - A zero-size request returns one shared non-null block. `uprv_realloc` treats that block as unallocated, and a resize of any other block to zero releases it and returns the shared block. - The callbacks stored by `u_setMemoryFunctions` are called with their context when set. Otherwise the blocks come from libc's guest heap, so a title releases them with `free`; the module exports no `uprv_free`. - `uprv_strndup` copies exactly `n` bytes, past a NUL, and a negative `n` duplicates the whole string. A null source throws where ICU faults. - The `Memory function configuration` debt entry no longer says that nothing calls the stored callbacks, and a new entry records what stays unverified. ### Tested - Windows (WinLibs GCC 15.2.0 `x86_64-ucrt-posix-seh` r7, the CI toolchain): `guest_icu_configuration` passes, and all 26 `icu` tests pass (`ctest -R icu`). - Linux (Ubuntu 24.04, GCC 13.3), outside the project build: `Configuration.cpp` and the test compiled with libc's `ApplicationHeap`, `ApplicationProcessParameters`, `GuestHeap`, `GuestArena` and `GuestAllocations` sources pass under UBSan and at `-O2`. - `core/libs/tests/test_public_headers.py --audit-only` and `tools/check_conventions.py` pass. - No title or console run; the behaviour comes from the ICU sources above. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QMWStysvjPgmgkKvPWyX1b

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!17629
No description provided.