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:
William S Fulton 2021-11-12 09:09:14 +00:00
commit ada739b4a8
2 changed files with 6 additions and 1 deletions

View file

@ -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;