/** * destroy function */ static void destroy(void) { LM_DBG("destroying module ...\n"); /* flush the state of the destinations */ if (ds_persistent_state) ds_flusher_routine(0, NULL); ds_partition_t *part_it = partitions, *aux; while (part_it) { ds_destroy_data(part_it); aux = part_it; part_it = part_it->next; ds_disconnect_db(aux); pkg_free(aux->db_handle); shm_free(aux); } /* destroy blacklists */ destroy_ds_bls(); /* destroy probing list */ if (ds_probing_list) free_int_list(ds_probing_list, NULL); }
/** * na_gtk_utils_restore_position_window: * @toplevel: the #GtkWindow window. * @wsp_name: the string which handles the window size and position in user preferences. * * Position the specified window on the screen. * * A window position is stored as a list of integers "x,y,width,height". */ void na_gtk_utils_restore_window_position( GtkWindow *toplevel, const gchar *wsp_name ) { static const gchar *thisfn = "na_gtk_utils_restore_window_position"; GList *list; gint x=0, y=0, width=0, height=0; GdkDisplay *display; GdkScreen *screen; gint screen_width, screen_height; g_return_if_fail( GTK_IS_WINDOW( toplevel )); g_return_if_fail( wsp_name && strlen( wsp_name )); g_debug( "%s: toplevel=%p (%s), wsp_name=%s", thisfn, ( void * ) toplevel, G_OBJECT_TYPE_NAME( toplevel ), wsp_name ); list = na_settings_get_uint_list( wsp_name, NULL, NULL ); if( list ){ int_list_to_position( list, &x, &y, &width, &height ); g_debug( "%s: wsp_name=%s, x=%d, y=%d, width=%d, height=%d", thisfn, wsp_name, x, y, width, height ); free_int_list( list ); } x = MAX( 1, x ); y = MAX( 1, y ); width = MAX( 1, width ); height = MAX( 1, height ); display = gdk_display_get_default(); screen = gdk_display_get_screen( display, 0 ); screen_width = gdk_screen_get_width( screen ); screen_height = gdk_screen_get_height( screen ); /* very dirty hack based on the assumption that Mate 2.x has a bottom * and a top panel bars, while Mate 3.x only has one. * Don't know how to get usable height of screen, and don't bother today. */ screen_height -= DEFAULT_HEIGHT; #if ! GTK_CHECK_VERSION( 3, 0, 0 ) screen_height -= DEFAULT_HEIGHT; #endif width = MIN( width, screen_width-x ); height = MIN( height, screen_height-y ); g_debug( "%s: wsp_name=%s, screen=(%d,%d), x=%d, y=%d, width=%d, height=%d", thisfn, wsp_name, screen_width, screen_height, x, y, width, height ); gtk_window_move( toplevel, x, y ); gtk_window_resize( toplevel, width, height ); }
static int w_ds_is_in_list(struct sip_msg *msg,char *ip,char *port,char *set, char *active_only) { ds_partition_t *partition = default_partition; int i_set = -1; if (set != NULL) { ds_param_t *setparam = (ds_param_t*)set; if (fixup_get_partition(msg, &setparam->partition, &partition) != 0) goto wrong_set_arg; if (setparam->sets == NULL) i_set = -1; else if (setparam->sets->type == GPARAM_TYPE_INT) { if (setparam->sets->next == NULL) i_set = setparam->sets->v.ival; else { LM_ERR("Only one set is allowed\n"); return -1; } } else { int_list_t *tmp_lst = set_list_from_pvs(msg, setparam->sets->v.pvs, NULL); if (tmp_lst == NULL){ LM_ERR("Wrong set var value\n"); return -1; } if (tmp_lst->next != NULL) { LM_ERR("Only one set is allowd\n"); return -1; } i_set = tmp_lst->v.ival; free_int_list(tmp_lst, NULL); } } if (partition == NULL) { LM_ERR ("unknown partition\n"); return -1; } return ds_is_in_list(msg, (gparam_t *)ip, (gparam_t *)port, i_set, (int)(long)active_only, partition); wrong_set_arg: LM_ERR("wrong format for set argument\n"); return -1; }
/** * na_gtk_utils_save_window_position: * @toplevel: the #GtkWindow window. * @wsp_name: the string which handles the window size and position in user preferences. * * Save the size and position of the specified window. */ void na_gtk_utils_save_window_position( GtkWindow *toplevel, const gchar *wsp_name ) { static const gchar *thisfn = "na_gtk_utils_save_window_position"; gint x, y, width, height; GList *list; g_return_if_fail( GTK_IS_WINDOW( toplevel )); g_return_if_fail( wsp_name && strlen( wsp_name )); gtk_window_get_position( toplevel, &x, &y ); gtk_window_get_size( toplevel, &width, &height ); g_debug( "%s: wsp_name=%s, x=%d, y=%d, width=%d, height=%d", thisfn, wsp_name, x, y, width, height ); list = position_to_int_list( x, y, width, height ); na_settings_set_uint_list( wsp_name, list ); free_int_list( list ); }
int alloc_and_load_timing_graph_levels (void) { /* Does a breadth-first search through the timing graph in order to levelize * * it. This allows subsequent breadth-first traversals to be faster. Also * * returns the number of sinks in the graph (nodes with no fanout). */ t_linked_int *free_list_head, *nodes_at_level_head; int inode, num_at_level, iedge, to_node, num_edges, num_sinks, num_levels, i; t_tedge *tedge; /* [0..num_tnodes-1]. # of in-edges to each tnode that have not yet been * * seen in this traversal. */ int *tnode_fanin_left; tnode_fanin_left = alloc_and_load_tnode_fanin_and_check_edges (&num_sinks); free_list_head = NULL; nodes_at_level_head = NULL; /* Very conservative -> max number of levels = num_tnodes. Realloc later. * * Temporarily need one extra level on the end because I look at the first * * empty level. */ tnodes_at_level = (struct s_ivec *) my_malloc ((num_tnodes + 1) * sizeof (struct s_ivec)); /* Scan through the timing graph, putting all the primary input nodes (no * * fanin) into level 0 of the level structure. */ num_at_level = 0; for (inode=0;inode<num_tnodes;inode++) { if (tnode_fanin_left[inode] == 0) { num_at_level++; nodes_at_level_head = insert_in_int_list (nodes_at_level_head, inode, &free_list_head); } } alloc_ivector_and_copy_int_list (&nodes_at_level_head, num_at_level, &tnodes_at_level[0], &free_list_head); num_levels = 0; while (num_at_level != 0) { /* Until there's nothing in the queue. */ num_levels++; num_at_level = 0; for (i=0;i<tnodes_at_level[num_levels - 1].nelem;i++) { inode = tnodes_at_level[num_levels - 1].list[i]; tedge = tnode[inode].out_edges; num_edges = tnode[inode].num_edges; for (iedge=0;iedge<num_edges;iedge++) { to_node = tedge[iedge].to_node; tnode_fanin_left[to_node]--; if (tnode_fanin_left[to_node] == 0) { num_at_level++; nodes_at_level_head = insert_in_int_list (nodes_at_level_head, to_node, &free_list_head); } } } alloc_ivector_and_copy_int_list (&nodes_at_level_head, num_at_level, &tnodes_at_level[num_levels], &free_list_head); } tnodes_at_level = (struct s_ivec *) my_realloc (tnodes_at_level, num_levels * sizeof (struct s_ivec)); num_tnode_levels = num_levels; free (tnode_fanin_left); free_int_list (&free_list_head); return (num_sinks); }
static void highlight_crit_path (void (*drawscreen_ptr) (void)) { /* Highlights all the blocks and nets on the critical path. */ t_linked_int *critical_path_head, *critical_path_node; int inode, iblk, inet, num_nets_seen; static int nets_to_highlight = 1; char msg[BUFSIZE]; if (nets_to_highlight == 0) { /* Clear the display of all highlighting. */ nets_to_highlight = 1; deselect_all (); update_message (default_message); drawscreen_ptr (); return; } critical_path_head = allocate_and_load_critical_path (); critical_path_node = critical_path_head; num_nets_seen = 0; while (critical_path_node != NULL) { inode = critical_path_node->data; get_tnode_block_and_output_net (inode, &iblk, &inet); if (num_nets_seen == nets_to_highlight) /* Last block */ block_color[iblk] = MAGENTA; else if (num_nets_seen == nets_to_highlight - 1) /* 2nd last block */ block_color[iblk] = YELLOW; else if (num_nets_seen < nets_to_highlight) /* Earlier block */ block_color[iblk] = DARKGREEN; if (inet != OPEN) { num_nets_seen++; if (num_nets_seen < nets_to_highlight) /* First nets. */ net_color[inet] = DARKGREEN; else if (num_nets_seen == nets_to_highlight) net_color[inet] = CYAN; /* Last (new) net. */ } critical_path_node = critical_path_node->next; } if (nets_to_highlight == num_nets_seen) { nets_to_highlight = 0; sprintf (msg, "All %d nets on the critical path highlighted.", num_nets_seen); } else { sprintf (msg, "First %d nets on the critical path highlighted.", nets_to_highlight); nets_to_highlight++; } free_int_list (&critical_path_head); update_message (msg); drawscreen_ptr (); }