Fix mismatched new char[] and free() - Javascript
Javascript - v8 and node only. When wrapping C code char arrays. Now calloc is now used instead of new char[] in SWIG_AsCharPtrAndSize. Fixes gcc-11 warning -Wmismatched-new-delete in arrays and memberin_extend testcases.
This commit is contained in:
parent
6cafc93135
commit
ada739b4a8
2 changed files with 6 additions and 1 deletions
|
|
@ -14,7 +14,7 @@ SWIG_AsCharPtrAndSize(SWIGV8_VALUE valRef, char** cptr, size_t* psize, int *allo
|
|||
%#endif
|
||||
|
||||
size_t len = SWIGV8_UTF8_LENGTH(js_str) + 1;
|
||||
char* cstr = new char[len];
|
||||
char* cstr = (char*) %new_array(len, char);
|
||||
SWIGV8_WRITE_UTF8(js_str, cstr, len);
|
||||
|
||||
if(alloc) *alloc = SWIG_NEWOBJ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue