Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 2e8c582

Browse files
brianjjonesgrgustaf
authored andcommitted
[gpio] Fix to allow JerryScript to release onchange callback (#755)
Signed-off-by: Brian Jones <[email protected]>
1 parent 7c5ff3c commit 2e8c582

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/zjs_gpio.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ typedef struct gpio_handle {
4747
uint32_t value; // Value of the pin
4848
zjs_callback_id callbackId; // ID for the C callback
4949
jerry_value_t pin_obj; // Pin object returned from open()
50-
jerry_value_t onchange_func; // Function registered to onChange
5150
jerry_value_t open_rval;
5251
uint32_t last;
5352
uint8_t edge_both;
@@ -119,14 +118,8 @@ static void gpio_c_callback(void *h, void *args)
119118
// Put the boolean GPIO trigger value in the object
120119
zjs_obj_add_boolean(event, val, "value");
121120

122-
// Only acquire once, once we have it just keep using it.
123-
// It will be released in close()
124-
if (!handle->onchange_func) {
125-
handle->onchange_func = jerry_acquire_value(onchange_func);
126-
}
127-
128121
// Call the JS callback
129-
jerry_call_function(handle->onchange_func, ZJS_UNDEFINED, &event, 1);
122+
jerry_call_function(onchange_func, ZJS_UNDEFINED, &event, 1);
130123

131124
jerry_release_value(event);
132125
} else {
@@ -239,9 +232,6 @@ static jerry_value_t zjs_gpio_pin_write(const jerry_value_t function_obj,
239232
static void zjs_gpio_close(gpio_handle_t *handle)
240233
{
241234
zjs_remove_callback(handle->callbackId);
242-
if (handle->onchange_func) {
243-
jerry_release_value(handle->onchange_func);
244-
}
245235
gpio_remove_callback(handle->port, &handle->callback);
246236
handle->closed = true;
247237
}

0 commit comments

Comments
 (0)