We currently have two instances of allocate() which allocate memory in JS and return to the C caller a c string:
iupemscripten_list.js: var c_str = allocate(intArrayFromString(ret_str), 'i8', ALLOC_NORMAL);
iupemscripten_text.js: var c_str = allocate(intArrayFromString(userText), 'i8', ALLOC_NORMAL);
The caller in C calls free() when it is done with this memory.
Potential problems:
1) The Emscripten documentation now discourages use of allocate() directly and suggests use _malloc() instead.
2) It is not clear if free() on the C-side actually and correctly frees memory created by allocate(). Perhaps a cleaner way to handle this is to callback into JavaScript passing back the pointer and calling _free().
We currently have two instances of allocate() which allocate memory in JS and return to the C caller a c string: iupemscripten_list.js: var c_str = allocate(intArrayFromString(ret_str), 'i8', ALLOC_NORMAL); iupemscripten_text.js: var c_str = allocate(intArrayFromString(userText), 'i8', ALLOC_NORMAL);
The caller in C calls free() when it is done with this memory.
Potential problems: 1) The Emscripten documentation now discourages use of allocate() directly and suggests use _malloc() instead.
2) It is not clear if free() on the C-side actually and correctly frees memory created by allocate(). Perhaps a cleaner way to handle this is to callback into JavaScript passing back the pointer and calling _free().