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 | 6fcb0d65e9cc15e161c6d86f7ab5eb46cae9c3b1 (patch) | |
tree | 39ddb0ad6e777dc693e192d3075f85cc9802356d /cocoa/ScintillaView.mm | |
parent | 3c4ee3e6f6344a3933383ed939f49c2f8d57e684 (diff) | |
download | scintilla-mirror-6fcb0d65e9cc15e161c6d86f7ab5eb46cae9c3b1.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; } } |