Use wxCoTaskMemPtr
Use RAII class wxCoTaskMemPtr to manage pointers that must be freed with ::CoTaskMemFree().
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/msw/private/winstyle.h"
|
||||
#include "wx/msw/private/cotaskmemptr.h"
|
||||
|
||||
#if wxUSE_UXTHEME
|
||||
#include "wx/msw/uxtheme.h"
|
||||
@@ -207,13 +208,13 @@ public:
|
||||
|
||||
const wxWX2WCbuf wcbuf = s.wc_str();
|
||||
const size_t size = (wcslen(wcbuf) + 1)*sizeof(wchar_t);
|
||||
void *olestr = CoTaskMemAlloc(size);
|
||||
wxCoTaskMemPtr<wchar_t> olestr(size);
|
||||
|
||||
if ( !olestr )
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
memcpy(olestr, wcbuf, size);
|
||||
|
||||
*rgelt++ = static_cast<LPOLESTR>(olestr);
|
||||
*rgelt++ = olestr.release();
|
||||
|
||||
++(*pceltFetched);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user