Skip to content

Audit use of "allocate" in js for correctness and memory leaks #34

@ewmailing

Description

@ewmailing

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions