/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv) ***************************************************************************** * @b Description: Function called to uninitialize the plugin ***************************************************************************** * @param priv : pointer on the private data of the plugin ***************************************************************************** * @remarks private data is freed by this function (g_free) ***************************************************************************** **/ static void vehicle_file_destroy(struct vehicle_priv *priv) { if (priv->statefile && priv->nmea_data) { struct attr readwrite={attr_readwrite}; struct attr create={attr_create}; struct attr *attrs[]={&readwrite,&create,NULL}; struct file *f; readwrite.u.num=1; create.u.num=1; f=file_create(priv->statefile, attrs); if (f) { file_data_write(f, 0, strlen(priv->nmea_data), priv->nmea_data); file_destroy(f); } } vehicle_file_close(priv); callback_destroy(priv->cb); callback_destroy(priv->cbt); if (priv->statefile) g_free(priv->statefile); if (priv->source) g_free(priv->source); if (priv->buffer) g_free(priv->buffer); g_free(priv); }
/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv) ***************************************************************************** * @b Description: Function called to uninitialize the plugin ***************************************************************************** * @param priv : pointer on the private data of the plugin ***************************************************************************** * @remarks private data is freed by this function (g_free) ***************************************************************************** **/ static void vehicle_file_destroy(struct vehicle_priv *priv) { vehicle_file_close(priv); callback_destroy(priv->cb); callback_destroy(priv->cbt); if (priv->source) g_free(priv->source); if (priv->buffer) g_free(priv->buffer); g_free(priv); }
void api_win_create( const char *const plugin_name, const char *tag, void *callback, void(*callback_exec)(PluginWindowCallback *window_callback, const char *tag, const char * const line), void(*callback_destroy)(void *callback)) { if (callbacks_win_exists(plugin_name, tag)) { if (callback_destroy) { callback_destroy(callback); } return; } PluginWindowCallback *window = malloc(sizeof(PluginWindowCallback)); window->callback = callback; window->callback_exec = callback_exec; window->callback_destroy = callback_destroy; callbacks_add_window_handler(plugin_name, tag, window); wins_new_plugin(plugin_name, tag); // set status bar active ProfPluginWin *pluginwin = wins_get_plugin(tag); int num = wins_get_num((ProfWin*)pluginwin); status_bar_active(num); }
/** @fn static void vehicle_file_close(struct vehicle_priv *priv) ***************************************************************************** * @b Description: close dialogue with the GPS ***************************************************************************** * @param priv : pointer on the private data of the plugin ***************************************************************************** **/ static void vehicle_file_close(struct vehicle_priv *priv) { dbg(1, "enter, priv->fd='%d'\n", priv->fd); vehicle_file_disable_watch(priv); #ifdef _WIN32 if(priv->file_type == file_type_serial) { if (priv->timeout_callback) { callback_destroy(priv->timeout_callback); priv->timeout_callback=NULL; // dangling pointer! prevent double freeing. } serial_io_shutdown( priv->fd ); } else #endif { if (priv->file) { #ifndef _MSC_VER pclose(priv->file); #endif /* _MSC_VER */ } else if (priv->fd >= 0) { close(priv->fd); } priv->file = NULL; priv->fd = -1; } }
static void vehicle_demo_destroy(struct vehicle_priv *priv) { if (priv->timer) event_remove_timeout(priv->timer); callback_destroy(priv->timer_callback); g_free(priv->timep); g_free(priv); }
void log_destroy(struct log *this_) { callback_destroy(this_->timer_callback); event_remove_timeout(this_->timer); log_flush(this_); log_close(this_); g_free(this_); }
void lifetime_end(lifetime_t *lifetime) { size_t count = voidp_vector_size(&lifetime->callbacks); for (size_t i = 0; i < count; i++) { nullary_callback_t *callback = (nullary_callback_t*) voidp_vector_get(&lifetime->callbacks, i); nullary_callback_call(callback); callback_destroy(callback); } voidp_vector_dispose(&lifetime->callbacks); native_mutex_dispose(&lifetime->guard); }
void gop_generic_free(op_generic_t *gop, int mode) { log_printf(20, "op_generic_free: before lock gid=%d\n", gop_get_id(gop)); lock_gop(gop); //** Make sure I own the lock just to be safe log_printf(20, "op_generic_free: AFTER lock gid=%d\n", gop_get_id(gop)); callback_destroy(gop->base.cb); //** Free the callback chain as well unlock_gop(gop); //** Make sure the lock is left in the proper state for reuse release_pigeon_coop_hole(_gop_control, &(gop->base.ctl->pch)); }
void log_destroy(struct log *this_) { dbg(0,"enter\n"); attr_list_free(this_->attrs); callback_destroy(this_->timer_callback); event_remove_timeout(this_->timer); log_flush(this_,0); log_close(this_); g_free(this_); }
static void script_destroy(struct script *scr) { dbg(lvl_debug,"enter %p\n",scr); if (scr->timeout) event_remove_timeout(scr->timeout); if (scr->cs) command_saved_destroy(scr->cs); callback_destroy(scr->cb); attr_list_free(scr->attrs); g_free(scr); }
void vehicle_webos_close(struct vehicle_priv *priv) { event_remove_timeout(priv->ev_timeout); priv->ev_timeout = NULL; callback_destroy(priv->timeout_cb); if (priv->pdk_version <= 100) PDL_UnregisterServiceCallback((PDL_ServiceCallbackFunc)vehicle_webos_callback); else { PDL_EnableLocationTracking(PDL_FALSE); vehicle_webos_bt_close(priv); } }
static void graphics_opengl_x11_destroy(struct graphics_opengl_window_system *x11) { if (x11->watch) event_remove_watch(x11->watch); if (x11->cb) callback_destroy(x11->cb); if (x11->display) { if (x11->window) XDestroyWindow(x11->display, x11->window); if (x11->colormap) XFreeColormap(x11->display, x11->colormap); XCloseDisplay(x11->display); } g_free(x11); }
/** @fn static void vehicle_file_close(struct vehicle_priv *priv) ***************************************************************************** * @b Description: close dialogue with the GPS ***************************************************************************** * @param priv : pointer on the private data of the plugin ***************************************************************************** **/ static void vehicle_file_close(struct vehicle_priv *priv) { dbg(1, "enter, priv->fd='%d'\n", priv->fd); vehicle_file_disable_watch(priv); #ifdef _WIN32 if (priv->timeout_callback) { callback_destroy(priv->timeout_callback); priv->timeout_callback=NULL; // dangling pointer! prevent double freeing. } serial_io_shutdown( priv->fd ); #else if (priv->file) pclose(priv->file); else if (priv->fd >= 0) close(priv->fd); priv->file = NULL; #endif priv->fd = -1; }
static void owner_disconnected(DBusConnection *connection, void *user_data) { struct obc_session *session = user_data; GError *err; DBG(""); /* * If connection still connecting notify the callback to destroy the * session. */ if (session->callback) { err = g_error_new(OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session closed by user"); callback_destroy(session->callback, err); g_error_free(err); return; } obc_session_shutdown(session); }
static void event_sdl_main_loop_run(void) { #ifdef USE_WEBOS_ACCELEROMETER struct callback* accel_cb = NULL; struct event_timeout* accel_to = NULL; if (PDL_GetPDKVersion() > 100) { accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr); accel_to = event_add_timeout(200, 1, accel_cb); } #endif graphics_sdl_idle(NULL); event_sdl_watch_stopthread(); #ifdef USE_WEBOS_ACCELEROMETER SDL_JoystickClose(accelerometer); if (PDL_GetPDKVersion() > 100) { event_remove_timeout(accel_to); callback_destroy(accel_cb); } #endif }
static void connect_cb(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct callback_data *callback = user_data; GError *gerr = NULL; uint8_t rsp_code; if (err != NULL) { error("connect_cb: %s", err->message); gerr = g_error_copy(err); goto done; } rsp_code = g_obex_packet_get_operation(rsp, NULL); if (rsp_code != G_OBEX_RSP_SUCCESS) gerr = g_error_new(OBEX_IO_ERROR, -EIO, "OBEX Connect failed with 0x%02x", rsp_code); done: callback_destroy(callback, gerr); if (gerr != NULL) g_error_free(gerr); }
static const VSFrameRef *_vszimg_get_frame(struct vszimg_data *data, const VSFrameRef *src_frame, VSCore *core, const VSAPI *vsapi, char *err_msg, size_t err_msg_size) { struct vszimg_graph_data *graph_data = NULL; VSFrameRef *dst_frame = NULL; VSFrameRef *ret = NULL; void *tmp = NULL; struct callback_data unpack_cb_data = { 0 }; struct callback_data pack_cb_data = { 0 }; zimg_image_format src_format; zimg_image_format dst_format; const VSFormat *src_vsformat; const VSFormat *dst_vsformat; const VSMap *src_props; VSMap *dst_props; size_t tmp_size; zimg_image_format_default(&src_format, ZIMG_API_VERSION); zimg_image_format_default(&dst_format, ZIMG_API_VERSION); src_props = vsapi->getFramePropsRO(src_frame); src_vsformat = vsapi->getFrameFormat(src_frame); dst_vsformat = data->vi.format ? data->vi.format : src_vsformat; src_format.width = vsapi->getFrameWidth(src_frame, 0); src_format.height = vsapi->getFrameHeight(src_frame, 0); dst_format.width = data->vi.width ? (unsigned)data->vi.width : src_format.width; dst_format.height = data->vi.height ? (unsigned)data->vi.height : src_format.height; if (translate_vsformat(src_vsformat, &src_format, err_msg)) goto fail; if (translate_vsformat(dst_vsformat, &dst_format, err_msg)) goto fail; _vszimg_set_src_colorspace(data, &src_format); if (import_frame_props(vsapi, src_props, &src_format, err_msg)) goto fail; _vszimg_set_dst_colorspace(data, &src_format, &dst_format); if (!(graph_data = _vszimg_get_graph_data(data, &src_format, &dst_format, err_msg, err_msg_size))) goto fail; dst_frame = vsapi->newVideoFrame(dst_vsformat, dst_format.width, dst_format.height, src_frame, core); dst_props = vsapi->getFramePropsRW(dst_frame); if (callback_init_unpack(&unpack_cb_data, graph_data->graph, src_frame, &src_format, src_vsformat, core, vsapi, err_msg, err_msg_size)) goto fail; if (callback_init_pack(&pack_cb_data, graph_data->graph, dst_frame, &dst_format, dst_vsformat, core, vsapi, err_msg, err_msg_size)) goto fail; if (zimg_filter_graph_get_tmp_size(graph_data->graph, &tmp_size)) { format_zimg_error(err_msg, err_msg_size); goto fail; } VS_ALIGNED_MALLOC(&tmp, tmp_size, 64); if (!tmp) { sprintf(err_msg, "error allocating temporary buffer"); goto fail; } if (zimg_filter_graph_process(graph_data->graph, &unpack_cb_data.line_buf.c, &pack_cb_data.line_buf.m, tmp, unpack_cb_data.cb, &unpack_cb_data, pack_cb_data.cb, &pack_cb_data)) { format_zimg_error(err_msg, err_msg_size); goto fail; } propagate_sar(vsapi, src_props, dst_props, &src_format, &dst_format); export_frame_props(vsapi, &dst_format, dst_props); ret = dst_frame; dst_frame = NULL; fail: _vszimg_release_graph_data(data, graph_data); vsapi->freeFrame(dst_frame); VS_ALIGNED_FREE(tmp); callback_destroy(&unpack_cb_data, vsapi); callback_destroy(&pack_cb_data, vsapi); return ret; }
static void transport_func(GIOChannel *io, GError *err, gpointer user_data) { struct callback_data *callback = user_data; struct obc_session *session = callback->session; struct obc_driver *driver = session->driver; struct obc_transport *transport = session->transport; GObex *obex; GObexApparam *apparam; GObexTransportType type; int tx_mtu = -1; int rx_mtu = -1; DBG(""); if (err != NULL) { error("%s", err->message); goto done; } g_io_channel_set_close_on_unref(io, FALSE); if (transport->getpacketopt && transport->getpacketopt(io, &tx_mtu, &rx_mtu) == 0) type = G_OBEX_TRANSPORT_PACKET; else type = G_OBEX_TRANSPORT_STREAM; obex = g_obex_new(io, type, tx_mtu, rx_mtu); if (obex == NULL) goto done; g_io_channel_set_close_on_unref(io, TRUE); apparam = NULL; if (driver->supported_features) apparam = driver->supported_features(session); if (apparam) { uint8_t buf[1024]; ssize_t len; len = g_obex_apparam_encode(apparam, buf, sizeof(buf)); if (driver->target) g_obex_connect(obex, connect_cb, callback, &err, G_OBEX_HDR_TARGET, driver->target, driver->target_len, G_OBEX_HDR_APPARAM, buf, len, G_OBEX_HDR_INVALID); else g_obex_connect(obex, connect_cb, callback, &err, G_OBEX_HDR_APPARAM, buf, len, G_OBEX_HDR_INVALID); g_obex_apparam_free(apparam); } else if (driver->target) g_obex_connect(obex, connect_cb, callback, &err, G_OBEX_HDR_TARGET, driver->target, driver->target_len, G_OBEX_HDR_INVALID); else g_obex_connect(obex, connect_cb, callback, &err, G_OBEX_HDR_INVALID); if (err != NULL) { error("%s", err->message); g_obex_unref(obex); goto done; } session->obex = obex; sessions = g_slist_prepend(sessions, session); g_obex_set_disconnect_function(obex, session_disconnected, session); return; done: callback_destroy(callback, err); }