Skip to content

Commit b894433

Browse files
committed
Merge remote branch 'davegb3/lint-fix-pass-1' into jl/lint-fix-pass-1
Conflicts: PythonScript/src/CreateWrapper.py PythonScript/src/PythonScript.cpp PythonScript/src/ScintillaWrapperGenerated.cpp
2 parents 82b7e3d + abb2180 commit b894433

File tree

3 files changed

+77
-77
lines changed

3 files changed

+77
-77
lines changed

PythonScript/src/CreateWrapper.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ def constString(v, out):
9797

9898
def retString(v, out):
9999
out.write("\tint resultLength = callScintilla(" + symbolName(v) + ");\n")
100-
out.write("\tchar *result = (char *)malloc(resultLength + 1);\n")
100+
out.write("\tchar *result = new char[resultLength + 1];\n")
101101
out.write("\tcallScintilla(" + symbolName(v) + ", resultLength + 1, reinterpret_cast<LPARAM>(result));\n")
102102
out.write("\tresult[resultLength] = '\\0';\n")
103-
out.write("\tboost::python::str o = boost::python::str(result);\n")
104-
out.write("\tfree(result);\n")
103+
out.write("\tboost::python::str o = boost::python::str(const_cast<const char *>(result));\n")
104+
out.write("\tdelete [] result;\n")
105105
out.write("\treturn o;\n")
106106

107107
def getLineBody(v, out):
@@ -113,11 +113,11 @@ def getLineBody(v, out):
113113
out.write("\telse\n")
114114
out.write("\t{\n")
115115
out.write("\t\tint resultLength = callScintilla(" + symbolName(v) + ", line);\n")
116-
out.write("\t\tchar *result = (char *)malloc(resultLength + 1);\n")
116+
out.write("\t\tchar *result = new char[resultLength + 1];\n")
117117
out.write("\t\tcallScintilla(" + symbolName(v) + ", line, reinterpret_cast<LPARAM>(result));\n")
118118
out.write("\t\tresult[resultLength] = '\\0';\n")
119-
out.write("\t\tboost::python::str o = boost::python::str(result);\n")
120-
out.write("\t\tfree(result);\n")
119+
out.write("\t\tboost::python::str o = boost::python::str((const char *)result);\n")
120+
out.write("\t\tdelete [] result;\n")
121121
out.write("\t\treturn o;\n")
122122
out.write("\t}\n")
123123

@@ -134,7 +134,7 @@ def retStringNoLength(v, out):
134134

135135
out.write(");\n")
136136

137-
out.write("\tchar *result = (char *)malloc(resultLength + 1);\n")
137+
out.write("\tchar *result = new char[resultLength + 1];\n")
138138
out.write("\tcallScintilla(" + symbolName(v) + ", ")
139139

140140
if v["Param1Type"] or v["Param2Type"]:
@@ -148,8 +148,8 @@ def retStringNoLength(v, out):
148148

149149
out.write(", reinterpret_cast<LPARAM>(result));\n")
150150
out.write("\tresult[resultLength] = '\\0';\n")
151-
out.write("\tboost::python::str o = boost::python::str(result);\n")
152-
out.write("\tfree(result);\n")
151+
out.write("\tboost::python::str o = boost::python::str(const_cast<const char *>(result));\n")
152+
out.write("\tdelete [] result;\n")
153153
out.write("\treturn o;\n")
154154

155155
def findTextBody(v, out):
@@ -176,7 +176,7 @@ def getTextRangeBody(v, out):
176176
out.write('\tsrc.lpstrText = new char[(end-start) + 1];\n')
177177
out.write('\tcallScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n'.format(symbolName(v)))
178178
out.write('\tboost::python::str ret(const_cast<const char*>(src.lpstrText));\n')
179-
out.write('\tdelete src.lpstrText;\n')
179+
out.write('\tdelete [] src.lpstrText;\n')
180180
out.write('\treturn ret;\n')
181181

182182

@@ -201,8 +201,8 @@ def getStyledTextBody(v, out):
201201
out.write('\t}\n')
202202
out.write("\tresult[end-start] = '\\0';\n")
203203
out.write('\tboost::python::str resultStr(const_cast<const char*>(result));\n')
204-
out.write('\tdelete src.lpstrText;\n')
205-
out.write('\tdelete result;\n')
204+
out.write('\tdelete [] src.lpstrText;\n')
205+
out.write('\tdelete [] result;\n')
206206
out.write('\treturn boost::python::make_tuple(resultStr, styles);\n')
207207

208208

PythonScript/src/PythonScript.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "HelpController.h"
1616
#include "PythonScript/NppPythonScript.h"
1717

18-
#define CHECK_INITIALIZED() if (!g_initialised) initialisePython()
18+
#define CHECK_INITIALISED() if (!g_initialised) initialisePython()
1919

2020
/* Info for Notepad++ */
2121
CONST TCHAR PLUGIN_NAME[] = _T("Python Script");
@@ -367,7 +367,7 @@ extern "C" __declspec(dllexport) LRESULT messageProc(UINT message, WPARAM wParam
367367
case PYSCR_EXECSCRIPT:
368368
case PYSCR_EXECSTATEMENT:
369369
{
370-
CHECK_INITIALIZED();
370+
CHECK_INITIALISED();
371371
PythonScript_Exec* pse = reinterpret_cast<PythonScript_Exec*>(ci->info);
372372
if (pse->structVersion != 1)
373373
{
@@ -484,7 +484,7 @@ void runScript(int number)
484484

485485
void runStatement(const char *statement, bool synchronous, HANDLE completedEvent /* = NULL */, bool allowQueuing /* = false */)
486486
{
487-
CHECK_INITIALIZED();
487+
CHECK_INITIALISED();
488488
MenuManager::getInstance()->stopScriptEnabled(true);
489489
if (!pythonHandler->runScript(statement, synchronous, allowQueuing, completedEvent, true))
490490
{
@@ -533,7 +533,7 @@ void runScript(const char *filename, bool synchronous, HANDLE completedEvent /*
533533
}
534534
else
535535
{
536-
CHECK_INITIALIZED();
536+
CHECK_INITIALISED();
537537
MenuManager::getInstance()->stopScriptEnabled(true);
538538

539539
// TODO: Really need to not change this if it's a MSGTOPLUGIN run
@@ -561,7 +561,7 @@ void showConsole()
561561
{
562562
if (g_console)
563563
{
564-
CHECK_INITIALIZED();
564+
CHECK_INITIALISED();
565565
g_console->showDialog();
566566
}
567567
}

0 commit comments

Comments
 (0)