@@ -97,11 +97,11 @@ def constString(v, out):
9797
9898def retString (v , out ):
9999 out .write ("\t int resultLength = callScintilla(" + symbolName (v ) + ");\n " )
100- out .write ("\t char *result = (char *)malloc( resultLength + 1) ;\n " )
100+ out .write ("\t char *result = new char[ resultLength + 1] ;\n " )
101101 out .write ("\t callScintilla(" + symbolName (v ) + ", resultLength + 1, reinterpret_cast<LPARAM>(result));\n " )
102102 out .write ("\t result[resultLength] = '\\ 0';\n " )
103- out .write ("\t boost::python::str o = boost::python::str(result);\n " )
104- out .write ("\t free( result) ;\n " )
103+ out .write ("\t boost::python::str o = boost::python::str(const_cast<const char *>( result) );\n " )
104+ out .write ("\t delete [] result;\n " )
105105 out .write ("\t return o;\n " )
106106
107107def getLineBody (v , out ):
@@ -113,11 +113,11 @@ def getLineBody(v, out):
113113 out .write ("\t else\n " )
114114 out .write ("\t {\n " )
115115 out .write ("\t \t int resultLength = callScintilla(" + symbolName (v ) + ", line);\n " )
116- out .write ("\t \t char *result = (char *)malloc( resultLength + 1) ;\n " )
116+ out .write ("\t \t char *result = new char[ resultLength + 1] ;\n " )
117117 out .write ("\t \t callScintilla(" + symbolName (v ) + ", line, reinterpret_cast<LPARAM>(result));\n " )
118118 out .write ("\t \t result[resultLength] = '\\ 0';\n " )
119- out .write ("\t \t boost::python::str o = boost::python::str(result);\n " )
120- out .write ("\t \t free( result) ;\n " )
119+ out .write ("\t \t boost::python::str o = boost::python::str((const char *) result);\n " )
120+ out .write ("\t \t delete [] result;\n " )
121121 out .write ("\t \t return 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 ("\t char *result = (char *)malloc( resultLength + 1) ;\n " )
137+ out .write ("\t char *result = new char[ resultLength + 1] ;\n " )
138138 out .write ("\t callScintilla(" + 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 ("\t result[resultLength] = '\\ 0';\n " )
151- out .write ("\t boost::python::str o = boost::python::str(result);\n " )
152- out .write ("\t free( result) ;\n " )
151+ out .write ("\t boost::python::str o = boost::python::str(const_cast<const char *>( result) );\n " )
152+ out .write ("\t delete [] result;\n " )
153153 out .write ("\t return o;\n " )
154154
155155def findTextBody (v , out ):
@@ -176,7 +176,7 @@ def getTextRangeBody(v, out):
176176 out .write ('\t src.lpstrText = new char[(end-start) + 1];\n ' )
177177 out .write ('\t callScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n ' .format (symbolName (v )))
178178 out .write ('\t boost::python::str ret(const_cast<const char*>(src.lpstrText));\n ' )
179- out .write ('\t delete src.lpstrText;\n ' )
179+ out .write ('\t delete [] src.lpstrText;\n ' )
180180 out .write ('\t return ret;\n ' )
181181
182182
@@ -201,8 +201,8 @@ def getStyledTextBody(v, out):
201201 out .write ('\t }\n ' )
202202 out .write ("\t result[end-start] = '\\ 0';\n " )
203203 out .write ('\t boost::python::str resultStr(const_cast<const char*>(result));\n ' )
204- out .write ('\t delete src.lpstrText;\n ' )
205- out .write ('\t delete result;\n ' )
204+ out .write ('\t delete [] src.lpstrText;\n ' )
205+ out .write ('\t delete [] result;\n ' )
206206 out .write ('\t return boost::python::make_tuple(resultStr, styles);\n ' )
207207
208208
0 commit comments