Skip to content

Make all dynamic memory allocations via core API functions in jerry-ext #4480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions jerry-ext/handle-scope/handle-scope-allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ jerryx_handle_scope_alloc (void)
}
else
{
jerryx_handle_scope_dynamic_t *dy_scope = malloc (sizeof (jerryx_handle_scope_dynamic_t));
jerryx_handle_scope_dynamic_t *dy_scope;
dy_scope = (jerryx_handle_scope_dynamic_t *) jerry_heap_alloc (sizeof (jerryx_handle_scope_dynamic_t));
JERRYX_ASSERT (dy_scope != NULL);
dy_scope->child = NULL;

Expand Down Expand Up @@ -216,7 +217,7 @@ jerryx_handle_scope_free (jerryx_handle_scope_t *scope)
{
dy_scope->parent->child = dy_scope->child;
}
free (dy_scope);
jerry_heap_free (dy_scope, sizeof (jerryx_handle_scope_dynamic_t));
return;
}
/**
Expand Down
8 changes: 4 additions & 4 deletions jerry-ext/handle-scope/handle-scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jerryx_handle_scope_release_handles (jerryx_handle_scope scope)
{
jerry_release_value (a_handle->jval);
jerryx_handle_t *sibling = a_handle->sibling;
free (a_handle);
jerry_heap_free (a_handle, sizeof (jerryx_handle_t));
a_handle = sibling;
}
scope->handle_ptr = NULL;
Expand Down Expand Up @@ -134,7 +134,7 @@ jerryx_hand_scope_escape_handle_from_prelist (jerryx_handle_scope scope, size_t
jerryx_handle_t *handle = scope->handle_ptr;
scope->handle_ptr = handle->sibling;
scope->handle_prelist[idx] = handle->jval;
free (handle);
jerry_heap_free (handle, sizeof (jerryx_handle_t));
return jval;
}

Expand Down Expand Up @@ -313,7 +313,7 @@ jerryx_handle_scope_add_handle_to (jerryx_handle_t *handle, jerryx_handle_scope
{
++scope->prelist_handle_count;
jerry_value_t jval = handle->jval;
free (handle);
jerry_heap_free (handle, sizeof (jerryx_handle_t));
scope->handle_prelist[prelist_handle_count] = jval;
return jval;
}
Expand Down Expand Up @@ -341,7 +341,7 @@ jerryx_create_handle_in_scope (jerry_value_t jval, jerryx_handle_scope scope)
++scope->prelist_handle_count;
return jval;
}
jerryx_handle_t *handle = malloc (sizeof (jerryx_handle_t));
jerryx_handle_t *handle = (jerryx_handle_t *) jerry_heap_alloc (sizeof (jerryx_handle_t));
JERRYX_ASSERT (handle != NULL);
handle->jval = jval;

Expand Down