GTree* version_extract_from_admin_tree(GTree *t) { GTree *v = version_empty(); g_tree_foreach(t, (GTraverseFunc)hook_extract, v); return v; }
/** * Cleanup all the resources for the object */ void xmms_object_cleanup (xmms_object_t *object) { g_return_if_fail (object); g_return_if_fail (XMMS_IS_OBJECT (object)); if (object->signals) { /* destroy the tree manually (ie not via a value_destroy_func * callback since we're often "replacing" values when we're * adding new elements to the signal lists. and we don't want * the value to be destroyed in those cases :) */ g_tree_foreach (object->signals, cleanup_signal_list, NULL); g_tree_destroy (object->signals); } if (object->cmds) { /* We don't need to free the commands themselves -- they are * stored in read-only memory. */ g_tree_destroy (object->cmds); } g_mutex_free (object->mutex); }
static gpointer idle_thread (gpointer data) { HTTPServer *http_server = (HTTPServer *)data; ForeachFuncData func_data; GSList *wakeup_list = NULL; func_data.http_server = http_server; func_data.wakeup_list = &wakeup_list; for (;;) { g_mutex_lock (&(http_server->idle_queue_mutex)); while (g_tree_nnodes (http_server->idle_queue) == 0) { g_cond_wait (&(http_server->idle_queue_cond), &(http_server->idle_queue_mutex)); } func_data.wakeup_time = 0; g_tree_foreach (http_server->idle_queue, gtree_foreach_func, &func_data); if (wakeup_list != NULL) { g_slist_foreach (wakeup_list, gslist_foreach_func, http_server); g_slist_free (wakeup_list); wakeup_list = NULL; } if (func_data.wakeup_time != 0) { /* more than one idle request in the idle queue, wait until. */ g_cond_wait_until (&(http_server->idle_queue_cond), &(http_server->idle_queue_mutex), func_data.wakeup_time); } g_mutex_unlock (&(http_server->idle_queue_mutex)); } return NULL; }
/* search next/prev playlist */ const struct playlist_info * irmpc_playlist_nextprev (int direction, const char *lookup_name) { struct irmpc_nextprev_playlist_traverse_data tdata = {direction, NULL, NULL, lookup_name}; g_tree_foreach (playlist_table, irmpc_nextprev_playlist_traverse, (gpointer) (&tdata)); return tdata.result; }
void EnumerateLibrary ( GTraverseFunc func, gpointer user_data ) { g_tree_foreach (PluckerDocs, func, user_data); }
static gboolean gconf_settings_backend_write_tree (GSettingsBackend *backend, GTree *tree, gpointer origin_tag) { GConfSettingsBackend *gconf = GCONF_SETTINGS_BACKEND (backend); GConfChangeSet *changeset; GConfChangeSet *reversed; gboolean success; changeset = gconf_change_set_new (); g_tree_foreach (tree, (GTraverseFunc) gconf_settings_backend_write_one_to_changeset, changeset); if (gconf_change_set_size (changeset) != g_tree_nnodes (tree)) { gconf_change_set_unref (changeset); return FALSE; } reversed = gconf_client_reverse_change_set (gconf->priv->client, changeset, NULL); success = gconf_client_commit_change_set (gconf->priv->client, changeset, TRUE, NULL); g_tree_foreach (tree, (GTraverseFunc) gconf_settings_backend_add_ignore_notifications, gconf); if (!success) { /* This is a tricky situation: when committing, some keys will have been * changed, so there will be notifications that we'll want to ignore. But * we can't ignore notifications for what was not committed. Note that * when we'll commit the reversed changeset, it should fail for the same * key, so there'll be no other notifications created. And in the worst * case, it's no big deal... */ gconf_change_set_foreach (changeset, (GConfChangeSetForeachFunc) gconf_settings_backend_remove_ignore_notifications, gconf); gconf_client_commit_change_set (gconf->priv->client, reversed, FALSE, NULL); } else g_settings_backend_changed_tree (backend, tree, origin_tag); gconf_change_set_unref (changeset); gconf_change_set_unref (reversed); return success; }
/* print playlist table - used for debugging */ void irmpc_playlist_print_debug () { if (playlist_table != NULL) { fprintf (stderr, "playlist:\n"); g_tree_foreach (playlist_table, irmpc_playlist_entry_print_debug, NULL); } else { fprintf (stderr, "playlist empty\n"); } }
int MailboxState_clear_recent(T M) { if (MailboxState_getPermission(M) == IMAPPERM_READWRITE && MailboxState_getMsginfo(M)) { GTree *info = MailboxState_getMsginfo(M); g_tree_foreach(info, (GTraverseFunc)mailbox_clear_recent, M); } return 0; }
gchar* version_dump(GTree *t) { EXTRA_ASSERT(t != NULL); GString *gstr = g_string_new(""); if (t) g_tree_foreach(t, hook_dump, gstr); return g_string_free(gstr, FALSE); }
GSList* meta0_utils_tree_to_list(GTree *byurl) { GSList *result = NULL; EXTRA_ASSERT(byurl != NULL); g_tree_foreach(byurl, _tree2list_traverser, &result); return result; }
/** * oscats_administrand_register_characteristic: * @characteristic: the #GQuark characteristic to register * * Adds @characteristic to the internal characteristics table. It is more * efficient to register all characteristics before creating administrands * than to add new characteristics after administrands already exist. */ void oscats_administrand_register_characteristic(GQuark characteristic) { int c = (static_initialized ? g_hash_table_size(quark_to_char) : 1); initialize_static(); g_hash_table_insert(quark_to_char, GUINT_TO_POINTER(characteristic), GUINT_TO_POINTER(c)); g_array_append_val(char_to_quark, characteristic); g_tree_foreach(administrands, add_characteristic, NULL); }
int MailboxState_merge_recent(T M, T N) { GTree *recent_queue = N->recent_queue; N->recent_queue = NULL; g_tree_merge(M->recent_queue, recent_queue, IST_SUBSEARCH_OR); g_tree_foreach(recent_queue, (GTraverseFunc)_free_recent_queue, M); g_tree_destroy(recent_queue); M->recent = g_tree_nnodes(M->recent_queue); return 0; }
int MailboxState_build_recent(T M) { if (MailboxState_getPermission(M) == IMAPPERM_READWRITE && MailboxState_getMsginfo(M)) { GTree *info = MailboxState_getMsginfo(M); g_tree_foreach(info, (GTraverseFunc)mailbox_build_recent, M); TRACE(TRACE_DEBUG, "build list of [%d] [%d] recent messages...", g_tree_nnodes(info), g_tree_nnodes(M->recent_queue)); } return 0; }
/** * Create a new #xmmsv_t dict initialized with the argument. * @param dict The dict of values to initially fill the #xmmsv_t with. * @return a new #xmmsv_t dict. */ static xmmsv_t * xmms_create_xmmsv_dict (GTree *dict) { xmmsv_t *v = NULL; if (dict) { v = xmmsv_new_dict (); g_tree_foreach (dict, create_xmmsv_dict_foreach, (gpointer) v); } return v; }
static void diagram_update_nodes(GtkWidget * canvas) { GList *delete_list = NULL; node_t *new_node = NULL; /* Deletes all nodes and updates traffic values */ /* TODO To reduce CPU usage, I could just as well update each specific * node in update_canvas_nodes and create a new timeout function that would * make sure that old nodes get deleted by calling update_nodes, but * not as often as with diagram_refresh_period */ nodes_catalog_update_all(); /* Check if there are any new nodes */ while ((new_node = new_nodes_pop())) check_new_node (new_node, canvas); /* Update nodes look and queue outdated canvas_nodes for deletion */ g_tree_foreach(canvas_nodes, (GTraverseFunc) canvas_node_update, &delete_list); /* delete all canvas nodes queued */ g_list_foreach(delete_list, gfunc_remove_canvas_node, NULL); /* free the list - list items are already destroyed */ g_list_free(delete_list); /* Limit the number of nodes displayed, if a limit has been set */ /* TODO check whether this is the right function to use, now that we have a more * general display_node called in update_canvas_nodes */ limit_nodes (); /* Reposition canvas_nodes */ if (need_reposition) { g_tree_foreach(canvas_nodes, (GTraverseFunc) reposition_canvas_nodes, canvas); need_reposition = FALSE; need_font_refresh = FALSE; } }
gchar* LookupKey(KeyTextList* list, const gchar* text) { if( list == NULL || list->tree == NULL || text == NULL ) return NULL; g_reverse_key = NULL; g_tree_foreach(list->tree, ReverseSearchFunc, (gpointer)text); return g_reverse_key; }
/* * Get breakpoints GTree for the given file * arguments: * file - file name to get breaks for */ GList* breaks_get_for_document(const char* file) { GList *breaks = NULL; GTree *tree = g_hash_table_lookup(files, file); if (tree) { g_tree_foreach(tree, tree_foreach_add_to_list, &breaks); } return breaks; }
/** * oscats_administrand_reset_characteristics: * * Removes all characteristics from the internal characteristics table. * (Useful for more compact memory management if you shift from * one large set of characteristics to another in the same program.) */ void oscats_administrand_reset_characteristics() { if (static_initialized) { g_hash_table_remove_all(quark_to_char); g_hash_table_insert(quark_to_char, 0, 0); g_array_set_size(char_to_quark, 1); g_tree_foreach(administrands, kill_characteristics, NULL); } }
static GString *purple_fbapi_construct_request_vargs(PurpleAccount *account, const char *method, va_list args) { GTree *params; const char *api_key, *api_secret; const char *key, *value; char call_id[21]; char *signature; GString *body; /* Read all paramters into a sorted tree */ params = g_tree_new((GCompareFunc)strcmp); while ((key = va_arg(args, const char *)) != NULL) { value = va_arg(args, const char *); g_tree_insert(params, (char *)key, (char *)value); /* If we have a session_key then we need a call_id */ if (g_str_equal(key, "session_key")) { struct timeval tv; if (gettimeofday(&tv, NULL) != 0) { time_t now; purple_debug_error("fbapi", "Error calling gettimeofday(): %s\n", g_strerror(errno)); now = time(NULL); strftime(call_id, sizeof(call_id), "%s000000", localtime(&now)); } else { char tmp[22]; strftime(tmp, sizeof(tmp), "%s", localtime(&tv.tv_sec)); sprintf(call_id, "%s%06lu", tmp, (long unsigned int)tv.tv_usec); } g_tree_insert(params, "call_id", call_id); } } api_key = purple_account_get_string(account, "fb_api_key", PURPLE_FBAPI_KEY); api_secret = purple_account_get_string(account, "fb_api_secret", API_SECRET); /* Add the method and api_key parameters to the list */ g_tree_insert(params, "method", (char *)method); g_tree_insert(params, "api_key", (char *)api_key); /* Add the signature parameter to the list */ signature = generate_signature((char *)api_secret, params); g_tree_insert(params, "sig", signature); /* Construct the body of the HTTP POST request */ body = g_string_new(NULL); g_tree_foreach(params, append_params_to_body, body); g_tree_destroy(params); g_free(signature); return body; }
static void find_range(GTree *c, uint64_t l, uint64_t r, GTree *a, gboolean uid) { struct filter_range_helper data; data.uid = uid; data.min = l; data.max = r; data.a = a; g_tree_foreach(c, (GTraverseFunc)filter_range, &data); }
void mpd_inotify_finish(void) { if (inotify_source == NULL) return; mpd_inotify_queue_finish(); mpd_inotify_source_free(inotify_source); g_tree_foreach(inotify_directories, free_watch_directory, NULL); g_tree_destroy(inotify_directories); }
gboolean cb_glext2d_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) { begin_x = event->x; begin_y = event->y; // left clicks will display info about the area clicked if (event->button == 1 && event->type == GDK_BUTTON_PRESS) { float x_pos_in_drawing_area = 0; float y_pos_in_drawing_area = 0; float height_width_ratio = (float) MAX(widget->allocation.width, widget->allocation.height)/MIN(widget->allocation.width, widget->allocation.height); float zoom_ratio = (float) view_scale / ZOOM_START_2D; float cube_size = .875 * zoom_ratio; float cube_size_scaled = (float) cube_size / height_width_ratio; float sidebar_size = (float) (1.0 - cube_size) / 2.0; float sidebar_size_scaled = (float) sidebar_size / height_width_ratio; float x_amount_moved = (float) trans_x / 4.0; float y_amount_moved = (float) trans_y / 4.0; float x_amount_moved_scaled = (float) x_amount_moved / height_width_ratio; float y_amount_moved_scaled = (float) y_amount_moved / height_width_ratio; float diff_in_width_height = (float) MAX(widget->allocation.width, widget->allocation.height) - (float) MIN(widget->allocation.width, widget->allocation.height); float extra_pixels_on_side = (float) diff_in_width_height / 2.0; float extra_pixels_ratio = (float) extra_pixels_on_side/MAX(widget->allocation.width, widget->allocation.height); if (widget->allocation.width >= widget->allocation.height) { // this line will make the range 0->1 always, no matter the width/height of the window x_pos_in_drawing_area = (float) (event->x) / ((float) widget->allocation.width - diff_in_width_height) / height_width_ratio; x_pos_in_white_square = (float) ((float) x_pos_in_drawing_area - (float) sidebar_size_scaled - (float) extra_pixels_ratio - (float) x_amount_moved_scaled) / (cube_size_scaled); y_pos_in_drawing_area = (float) (event->y) / ((float) widget->allocation.height); y_pos_in_white_square = (float) ((float) y_pos_in_drawing_area - (float) sidebar_size - (float) y_amount_moved) / (cube_size); } else { // this line will make the range 0->1 always, no matter the width/height of the window x_pos_in_drawing_area = (float) (event->x) / ((float) widget->allocation.width); x_pos_in_white_square = (float) ((float) x_pos_in_drawing_area - (float) sidebar_size - (float) x_amount_moved) / (cube_size); y_pos_in_drawing_area = (float) (event->y) / ((float) widget->allocation.height - diff_in_width_height) / height_width_ratio; y_pos_in_white_square = (float) ((float) y_pos_in_drawing_area - (float) sidebar_size_scaled - (float) extra_pixels_ratio - (float) y_amount_moved_scaled) / (cube_size_scaled); } // translate from 0->1 coordinates to -1->1 x_pos_in_white_square = x_pos_in_white_square * 2 - 1; y_pos_in_white_square = y_pos_in_white_square * 2 - 1; // loop through nodes and look for a match GtkTreeIter iter; g_tree_foreach(viz->nodes, gtree_foreach_check_match, &iter); } return FALSE; }
gboolean test1_user_function2 (AfDalData * register_data, gpointer user_data) { printf ("Active server list:\n"); if (register_data->state == AFDAL_OK) { g_tree_foreach (register_data->data, print_active_server, NULL); test1_exit_var2 = TRUE; }else { printf ("ERROR: Recieved an error msg\n"); exit (-1); } return TRUE; }
/** * @brief Clears the contents of a GTree * * @param tree the tree to remove all elements from */ void g_tree_clear(GTree* tree) { GList* keys = NULL; GList* iter = NULL; g_tree_foreach(tree, g_tree_collect, &keys); for(iter = keys; iter != NULL; iter = iter->next) g_tree_remove(tree, iter->data); g_list_free(keys); }
int8_t _PtnReduceSlot(THREAD_SLOT *a_Param, uint64_t ulSize) { int8_t cRtnCode = SUCCESS; uint16_t usCntMin = USHRT_MAX; uint64_t ulIdx; for (ulIdx = 0 ; ulIdx < ulSize ; ulIdx++) { if (a_Param[ulIdx].a_BlkCand->len < usCntMin) usCntMin = a_Param[ulIdx].a_BlkCand->len; } /* Let the common block list extracted from the first slot be the comparison base. */ THREAD_SLOT *p_Param = a_Param; GPtrArray *a_BlkCandB = p_Param->a_BlkCand; /* Iteratively compare the rest block lists with the base. */ uint16_t usIdx; for (usIdx = 0 ; usIdx < usCntMin ; usIdx++) { BLOCK_CAND *p_BlkCandB = g_ptr_array_index(a_BlkCandB, usIdx); uint16_t *a_usCtnB = p_BlkCandB->a_usCtn; GTree *t_CtnAddrB = p_BlkCandB->t_CtnAddr; for (ulIdx = 1 ; ulIdx < ulSize ; ulIdx++) { p_Param = a_Param + ulIdx; GPtrArray *a_BlkCandC = p_Param->a_BlkCand; BLOCK_CAND *p_BlkCandC = g_ptr_array_index(a_BlkCandC, usIdx); uint16_t *a_usCtnC = p_BlkCandC->a_usCtn; GTree *t_CtnAddrC = p_BlkCandC->t_CtnAddr; uint8_t ucIdx; for (ucIdx = 0 ; ucIdx < p_Conf->ucSizeBlk ; ucIdx++) { if (a_usCtnB[ucIdx] != a_usCtnC[ucIdx]) a_usCtnB[ucIdx] = WILD_CARD_MARK; } g_tree_foreach(t_CtnAddrC, DsTravContentAddrCopy, t_CtnAddrB); } uint8_t ucIdx; for (ucIdx = 0 ; ucIdx < p_Conf->ucSizeBlk ; ucIdx++) { uint16_t usMat = a_usCtnB[ucIdx]; if ((usMat == BYTE_NOISE_00) || (usMat == BYTE_NOISE_FF)) p_BlkCandB->ucCntNoise++; if (usMat == WILD_CARD_MARK) p_BlkCandB->ucCntWild++; } } EXIT: return cRtnCode; }
static gboolean g_keyfile_settings_backend_write_tree (GSettingsBackend *backend, GTree *tree, gpointer origin_tag) { WriteManyData data = { G_KEYFILE_SETTINGS_BACKEND (backend) }; if (!data.kfsb->writable) return FALSE; g_tree_foreach (tree, g_keyfile_settings_backend_check_one, &data); if (data.failed) return FALSE; g_tree_foreach (tree, g_keyfile_settings_backend_write_one, &data); g_keyfile_settings_backend_keyfile_write (data.kfsb); g_settings_backend_changed_tree (backend, tree, origin_tag); return TRUE; }
void prev_process_info__garbage_collector(cdtime_t tm) { /* {{{ */ prev_process_info__userdata_t userdata; GSList *cur; userdata.gl = NULL; userdata.tm = tm; g_tree_foreach(prev_process_info, prev_process_info__check_unused, &userdata); for(cur=userdata.gl; cur; cur = cur->next) { g_tree_remove(prev_process_info, cur->data); } g_slist_free(userdata.gl); } /* }}} */
char * tree_as_string(GTree *t) { char *result; GString *s = g_string_new(""); TRACE(TRACE_DEBUG,"start"); g_tree_foreach(t,(GTraverseFunc)_node_cat,&s); TRACE(TRACE_DEBUG,"done"); result = s->str; g_string_free(s,FALSE); return result; }
char * implode_hosttree(GTree *tree, char *delimiter) { char *result; struct implode_parameters params; params.delimiter = delimiter; params.buf = g_string_new(""); g_tree_foreach(tree, implode_helper, ¶ms); result = malloc(params.buf->len + 1); strncpy(result, params.buf->str, params.buf->len); result[params.buf->len] = 0; g_string_free(params.buf, TRUE); return result; }
/* free playlist info (table + strings) */ void irmpc_playlist_free () { if (playlist_table != NULL) { g_tree_foreach (playlist_table, irmpc_playlist_entry_free, NULL); g_tree_destroy (playlist_table); playlist_table = NULL; } if (playlist_name_storage != NULL) { g_string_chunk_free (playlist_name_storage); playlist_name_storage = NULL; } }