diff options
author | nyamatongwe <nyamatongwe@gmail.com> | 2013-05-04 19:15:44 +1000 |
---|---|---|
committer | nyamatongwe <nyamatongwe@gmail.com> | 2013-05-04 19:15:44 +1000 |
commit | 4a12e2cb25ee64333acab9ae60a4052105a02242 (patch) | |
tree | edd567a3f46cd67cc9bd3cd10a3c954401d2de3c /cocoa/ScintillaView.mm | |
parent | ec0e8f021798589fc5f23312bd2a0f3b2dfeabab (diff) | |
download | scintilla-mirror-4a12e2cb25ee64333acab9ae60a4052105a02242.tar.gz |
Replacing raw pointers and allocations with std::string and std::vector.
Don't check result of new as failures throw an exception.
Diffstat (limited to 'cocoa/ScintillaView.mm')
-rw-r--r-- | cocoa/ScintillaView.mm | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 7f6b4991e..30cc614f4 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -1223,22 +1223,18 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa { NSString *result = @""; - char *buffer(0); const long length = mBackend->WndProc(SCI_GETSELTEXT, 0, 0); if (length > 0) { - buffer = new char[length + 1]; + std::string buffer(length + 1, '\0'); try { - mBackend->WndProc(SCI_GETSELTEXT, length + 1, (sptr_t) buffer); + mBackend->WndProc(SCI_GETSELTEXT, length + 1, (sptr_t) &buffer[0]); - result = [NSString stringWithUTF8String: buffer]; - delete[] buffer; + result = [NSString stringWithUTF8String: buffer.c_str()]; } catch (...) { - delete[] buffer; - buffer = 0; } } @@ -1255,22 +1251,18 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa { NSString *result = @""; - char *buffer(0); const long length = mBackend->WndProc(SCI_GETLENGTH, 0, 0); if (length > 0) { - buffer = new char[length + 1]; + std::string buffer(length + 1, '\0'); try { - mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) buffer); + mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) &buffer[0]); - result = [NSString stringWithUTF8String: buffer]; - delete[] buffer; + result = [NSString stringWithUTF8String: buffer.c_str()]; } catch (...) { - delete[] buffer; - buffer = 0; } } |