Swift - withTemporaryAllocation, 이제 안전하게 쓸 수 있어요!
기존 withUnsafeTemporaryAllocation은 스택 임시 메모리를 할당해주지만, UnsafeMutableBufferPointer를 직접 다뤄야 해서 초기화/해제를 수동으로 관리해야 했어요. 에러 발생 시 deinit을 빠뜨리면 조용한 버그로 이어지는 위험이 있었죠. SE-0524는 이를 OutputSpan, OutputRawSpan과 결합해 안전한 전역 함수 두 가지를 추가합니다. withTemporaryAllocation(of:capacity:)는 inout OutputSpan를, withTemporaryAllocation(byteCount:alignment:)는 inout OutputRawSpan을 yield해요. defer 블록이 초기화된 요소를 자동으로 추적하고 해제해주기 때문에, 개발자는 포인터 관리 없이 append()만으로 안전하게 임시 메모리를 다룰 수 있게 됩니다. Swift 6.4에 구현 완료된 additive 변경이라 기존 코드에 영향 없어요. unsafe API가 부담스러웠던 분들께 특히 반가운 소식일것 같아요! https://green1229.tistory.com/619