From c30b2843733258fb2024d204238bd7ec1b960ea9 Mon Sep 17 00:00:00 2001 From: Vitaly Orekhov Date: Tue, 5 Mar 2024 11:42:27 +0300 Subject: [PATCH] [ATL] Implement CSimpleStringT::Preallocate (#6574) Used in `ATL::CStringW` and `ATL::CStringA`, for example: ``` ATL::CStringW cswItemText = ""; cswItemText.Preallocate(64); SendDlgItemMessageW(pdis->CtlID, LB_GETTEXT, pdis->itemID, reinterpret_cast(cswItemText.GetBuffer())); cswItemText.ReleaseBuffer(); ``` This public function is used to allocate memory for the string via private PrepareWrite, but it's missing somehow. Now it shouldn't be. --- sdk/lib/atl/atlsimpstr.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/lib/atl/atlsimpstr.h b/sdk/lib/atl/atlsimpstr.h index 2b571a299e0..ce0286602b4 100644 --- a/sdk/lib/atl/atlsimpstr.h +++ b/sdk/lib/atl/atlsimpstr.h @@ -373,6 +373,11 @@ public: return m_pszData; } + void Preallocate(_In_ int nLength) + { + PrepareWrite(nLength); + } + void ReleaseBufferSetLength(_In_ int nNewLength) { ATLASSERT(nNewLength >= 0);