@@ -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,
239232static 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