llvm-project
96f5dc4b - [libc] Use CheckedPtr in strdup, strndup and __sched_cpualloc (#241332)

Commit
1 day ago
[libc] Use CheckedPtr in strdup, strndup and __sched_cpualloc (#241332) Replace raw AllocChecker + new[] allocations in internal::strdup, strndup and __sched_cpualloc with make_unique_for_overwrite, and update internal::strdup to return CheckedPtr<T[]> instead of cpp::optional<T *>. While there, add an implicit CheckedPtr(cpp::nullptr_t) constructor so functions returning CheckedPtr can simply `return nullptr` on error/null input (the resulting CheckedPtr is still unchecked, so callers still have to inspect it) I add bazel rules for unique_ptr and CheckedPtr to as these are the first targets that need them. Assisted-by: Gemini
Author
Parents
Loading