[libc][stdlib] Use structure bindings instead of output params (#196169)
Refactored alloc_and_copy to return cpp::optional<AllocResult> instead
of using reference-to-pointer output parameters. The combination of char
**& parameters with array new/delete is known to trigger a segfault in
GCC 12's waccess GIMPLE pass.
The AllocResult struct holds the two allocated arrays (storage and
ownership). Call sites use structured bindings to unpack the result
after checking for nullopt.
Hopefully fixes the build failure in PR #195260 on the
libc-x86_64-debian-gcc-fullbuild-dbg builder.
Assisted-by: Automated tooling, human reviewed.
GitOrigin-RevId: 3637547de158fe7f244fd3e330d288fd66776a1c
2 files changed