Exemplo n.º 1
0
/**
 * 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);
}
Exemplo n.º 2
0
void MailboxState_free(T *M)
{
	T s = *M;
	if (s->name) 
		p_string_free(s->name, TRUE);

	g_tree_destroy(s->keywords);
	s->keywords = NULL;

	if (s->msn) g_tree_destroy(s->msn);
	s->msn = NULL;

	if (s->ids) g_tree_destroy(s->ids);		
	s->ids = NULL;

	if (s->msginfo) g_tree_destroy(s->msginfo);
	s->msginfo = NULL;

	if (s->recent_queue) {
		g_tree_foreach(s->recent_queue, (GTraverseFunc)_free_recent_queue, s);
		g_tree_destroy(s->recent_queue);
	}
	s->recent_queue = NULL;

	gboolean freepool = s->freepool;
	Mempool_T pool = s->pool;
	mempool_push(pool, s, sizeof(*s));

	if (freepool) {
		mempool_close(&pool);
	}

	s = NULL;
}
Exemplo n.º 3
0
static GTree* service_filegetter_import_download_specs(service_filegetter_tp sfg, service_filegetter_multi_args_tp args) {
	/* reads file with lines of the form:
	 * fileserver.shd:8080:/5mb.urnd
	 */

	if(args->server_specification_filepath == NULL) {
		service_filegetter_log(sfg, SFG_CRITICAL, "please specify a path to a download specification file");
		return NULL;
	}

	FILE* specs = fopen(args->server_specification_filepath, "r");
	if(specs == NULL) {
		service_filegetter_log(sfg, SFG_CRITICAL, "could not open file");
		perror(args->server_specification_filepath);
		return NULL;
	}

	gchar linebuffer[512];
	GTree* dlTree = g_tree_new_full(_treeIntCompare, NULL, g_free, g_free);
	gint counter = 0;

	while(fgets(linebuffer, sizeof(linebuffer), specs) != NULL) {
		/* strip off the newline */
		if (linebuffer[strlen(linebuffer) - 1] == '\n') {
			linebuffer[strlen(linebuffer) - 1] = '\0';
		}

		gchar** tokens = g_strsplit((const gchar*) linebuffer, (const gchar*)":", 3);
		if(g_strrstr(tokens[2], ":") != NULL) {
			service_filegetter_log(sfg, SFG_CRITICAL, "format of download specification file incorrect. expected something like \"fileserver.shd:8080:/5mb.urnd\" on each line");
			g_strfreev(tokens);
			g_tree_destroy(dlTree);
			return NULL;
		}

		service_filegetter_server_args_t http;
		http.host = tokens[0];
		http.port = tokens[1];
		gchar* filepath = tokens[2];

		service_filegetter_download_tp dl = service_filegetter_get_download_from_args(sfg, &http, &args->socks_proxy, filepath, args->hostbyname_cb);

		g_strfreev(tokens);

		if(dl == NULL) {
			service_filegetter_log(sfg, SFG_CRITICAL, "error parsing download specification file");
			g_tree_destroy(dlTree);
			return NULL;
		}

		gint* key = g_new(gint, 1);
		*key = counter++;
		g_tree_insert(dlTree, key, dl);
	}

	fclose(specs);

	return dlTree;
}
Exemplo n.º 4
0
static void MailboxState_uid_msn_new(T M)
{
	if (M->msn) g_tree_destroy(M->msn);
	M->msn = g_tree_new_full((GCompareDataFunc)ucmpdata,NULL,NULL,NULL);

	if (M->ids) g_tree_destroy(M->ids);
	M->ids = g_tree_new_full((GCompareDataFunc)ucmpdata,NULL,NULL,(GDestroyNotify)g_free);
}
Exemplo n.º 5
0
static void
test_pipefrom_version(struct cfg_s *cfg0, struct cfg_s *cfg1, gint64 r)
{
	gint64 worst = 0;
	GTree *v0 = build_version(cfg0);
	GTree *v1 = build_version(cfg1);
	GError *err = version_validate_diff(v0, v1, &worst);
	g_assert_error(err, GQD("sqliterepo"), CODE_PIPEFROM);
	g_assert(r == worst);
	g_tree_destroy(v0);
	g_tree_destroy(v1);
}
Exemplo n.º 6
0
static void
test_concurrent_version(struct cfg_s *cfg0, struct cfg_s *cfg1)
{
	gint64 worst = 0;
	GTree *v0 = build_version(cfg0);
	GTree *v1 = build_version(cfg1);
	GError *err = version_validate_diff(v0, v1, &worst);
	g_assert_error(err, GQD("sqliterepo"), CODE_CONCURRENT);
	g_assert(0 == worst);
	g_tree_destroy(v0);
	g_tree_destroy(v1);
}
Exemplo n.º 7
0
static void
test_noerror_version(struct cfg_s *c0, struct cfg_s *c1, gint64 r)
{
	gint64 worst = 0;
	GTree *v0 = build_version(c0);
	GTree *v1 = build_version(c1);
	GError *err = version_validate_diff(v0, v1, &worst);
	g_assert_no_error(err);
	g_assert(worst == r);
	g_tree_destroy(v0);
	g_tree_destroy(v1);
}
Exemplo n.º 8
0
static void __ice_agent_free_components(struct ice_agent *ag) {
	g_queue_clear(&ag->triggered);
	g_hash_table_destroy(ag->candidate_hash);
	g_hash_table_destroy(ag->pair_hash);
	g_hash_table_destroy(ag->transaction_hash);
	g_hash_table_destroy(ag->foundation_hash);
	g_tree_destroy(ag->all_pairs);
	g_queue_clear(&ag->all_pairs_list);
	g_tree_destroy(ag->nominated_pairs);
	g_tree_destroy(ag->succeeded_pairs);
	g_tree_destroy(ag->valid_pairs);
	ice_candidates_free(&ag->remote_candidates);
	ice_candidate_pairs_free(&ag->candidate_pairs);
}
Exemplo n.º 9
0
static void
context_flush_pending(struct sqlx_repctx_s *ctx)
{
	void _clean_value(gpointer v) {
		if (v)
			g_tree_destroy(v);
	}

	if (!ctx)
		return;
	if (ctx->pending)
		g_tree_destroy(ctx->pending);
	ctx->pending = g_tree_new_full(hashstr_quick_cmpdata, NULL,
			g_free, _clean_value);
}
Exemplo n.º 10
0
/*
* disposes the Gobject
*/
void classbrowser_backend_dispose (GObject *object)
{
  Classbrowser_Backend *classback = CLASSBROWSER_BACKEND(object);
  Classbrowser_BackendDetails *classbackdet;
	classbackdet = CLASSBROWSER_BACKEND_GET_PRIVATE(classback);
  /* free object resources*/
  if (classbackdet->functionlist){
   g_slist_foreach (classbackdet->functionlist, free_function_list_item, NULL);
   g_slist_free (classbackdet->functionlist);
  }
  if (classbackdet->php_variables_tree) g_tree_destroy (classbackdet->php_variables_tree);
  if (classbackdet->php_class_tree) g_tree_destroy (classbackdet->php_class_tree);
  /* Chain up to the parent class */
  G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gchar* _make_base_string(
                                GSignondSessionData *session_data, 
                                SoupURI* uri, gchar* nonce, gchar* timestamp)
{
    GString* base_string = g_string_new("POST&");
    
    gchar* base_uri;
    if (soup_uri_uses_default_port(uri))
        base_uri = g_strdup_printf("https://%s%s", soup_uri_get_host(uri),
                                                    soup_uri_get_path(uri));
    else
        base_uri = g_strdup_printf("https://%s:%u%s", soup_uri_get_host(uri),
                                                       soup_uri_get_port(uri),
                                                       soup_uri_get_path(uri));
    gchar* base_uri_e = _percent_encode(base_uri);
    g_string_append(base_string, base_uri_e);
    g_string_append(base_string, "&");
    g_free(base_uri);
    g_free(base_uri_e);
    
    GTree* parameters = g_tree_new((GCompareFunc)g_strcmp0);
    
    const gchar* query_s = soup_uri_get_query(uri);
    GHashTable* query;
    if (query_s != NULL)
        query = soup_form_decode(query_s);
    else    
        query = soup_form_decode("");
   
    g_hash_table_foreach(query, _insert_into_tree, parameters);
    
    const gchar* callback_uri = gsignond_dictionary_get_string(session_data, "Callback");
    if (callback_uri != NULL)
        g_tree_insert(parameters, "oauth_callback", (gchar*)callback_uri);
    const gchar* oauth_verifier = gsignond_dictionary_get_string(session_data, "_OauthVerifier");
    if (oauth_verifier != NULL)
        g_tree_insert(parameters, "oauth_verifier", (gchar*)oauth_verifier);
    g_tree_insert(parameters, "oauth_consumer_key", (gchar*)gsignond_dictionary_get_string(session_data, "ConsumerKey"));
    const gchar* oauth_temp_token = gsignond_dictionary_get_string(session_data, "_OauthTemporaryToken");
    if (oauth_temp_token != NULL)
        g_tree_insert(parameters, "oauth_token", (gchar*)oauth_temp_token);
    g_tree_insert(parameters, "oauth_signature_method", (gchar*)gsignond_dictionary_get_string(session_data, "SignatureMethod"));
    g_tree_insert(parameters, "oauth_nonce", nonce);
    g_tree_insert(parameters, "oauth_timestamp", timestamp);
    g_tree_insert(parameters, "oauth_version", "1.0");
    
    GString* parameters_string = g_string_new(NULL);
    g_tree_foreach(parameters, _make_parameters_string, parameters_string);
    gchar* parameters_s = g_string_free(parameters_string, FALSE);
    parameters_s[strlen(parameters_s)-1] = '\0'; //remove trailing '&'
    gchar* parameters_encoded = _percent_encode(parameters_s);
    g_string_append(base_string, parameters_encoded);
    
    g_free(parameters_encoded);
    g_free(parameters_s);
    g_tree_destroy(parameters);
    g_hash_table_destroy(query);
    
    return g_string_free(base_string, FALSE);
}
Exemplo n.º 12
0
static void
filter_in_list_free(FilterExprNode *s)
{
  FilterInList *self = (FilterInList *)s;

  g_tree_destroy(self->tree);
}
Exemplo n.º 13
0
static gchar *symbol_bd_sql_get_symbols_matches (Symbolizable *self, const gchar *symbol_prefix, gint flags)
{
  gphpedit_debug (DEBUG_SYMBOLIZABLE);
  SymbolBdSQLDetails *symbolbddet;
  symbolbddet = SYMBOL_BD_SQL_GET_PRIVATE(self);
  symbolbddet->completion_prefix = (gchar *) symbol_prefix;
  symbolbddet->completion_string = NULL;

  if (symbol_bd_sql_has_cache(symbolbddet->cache_str, symbolbddet->cache_completion, symbolbddet->cache_flags, symbol_prefix, flags)){
    symbolbddet->completion_string = symbol_bd_get_autocomp_from_cache(symbolbddet->cache_str, symbolbddet->cache_completion, symbol_prefix);
  } else {
    symbolbddet->completion_tree = g_tree_new_full ((GCompareDataFunc) g_strcmp0, NULL, NULL,(GDestroyNotify) g_free);

    if (((flags & SYMBOL_ALL) == SYMBOL_ALL) || ((flags & SYMBOL_FUNCTION) == SYMBOL_FUNCTION)) {
      /* add api functions */
      g_tree_foreach (symbolbddet->sql_api_tree, add_api_item, symbolbddet);
    }
    g_tree_foreach (symbolbddet->completion_tree, make_result_string, symbolbddet);
    g_tree_destroy (symbolbddet->completion_tree);
    if (symbolbddet->completion_string) symbol_bd_sql_save_result_in_cache(symbolbddet, symbolbddet->completion_string->str, symbol_prefix);
  }

  if (symbolbddet->completion_string){
    gphpedit_debug_message(DEBUG_CLASSBROWSER, "prefix: %s autocomplete list:%s\n", symbol_prefix, symbolbddet->completion_string->str);
    return g_string_free(symbolbddet->completion_string, FALSE);
  }

  gphpedit_debug_message(DEBUG_CLASSBROWSER, "prefix: %s autocomplete list:%s\n", symbol_prefix, "null");
  return NULL;
}
Exemplo n.º 14
0
static void
ibus_hotkey_profile_destroy (IBusHotkeyProfile *profile)
{
    IBusHotkeyProfilePrivate *priv;
    priv = IBUS_HOTKEY_PROFILE_GET_PRIVATE (profile);

    /* free events */
    if (priv->events) {
        IBusHotkeyEvent *p;
        gint i;
        p = (IBusHotkeyEvent *)g_array_free (priv->events, FALSE);
        priv->events = NULL;

        for (i = 0; p[i].event != 0; i++) {
            g_list_free (p[i].hotkeys);
        }
        g_free (p);
    }

    if (priv->hotkeys) {
        g_tree_destroy (priv->hotkeys);
        priv->hotkeys = NULL;
    }

    IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)profile);
}
Exemplo n.º 15
0
Arquivo: server.c Projeto: o9000/tint2
void cleanup_server()
{
	if (server.colormap)
		XFreeColormap(server.display, server.colormap);
	server.colormap = 0;
	if (server.colormap32)
		XFreeColormap(server.display, server.colormap32);
	server.colormap32 = 0;
	if (server.monitors) {
		for (int i = 0; i < server.num_monitors; ++i) {
			g_strfreev(server.monitors[i].names);
			server.monitors[i].names = NULL;
		}
		free(server.monitors);
		server.monitors = NULL;
	}
	if (server.gc)
		XFreeGC(server.display, server.gc);
	server.gc = NULL;
	server.disable_transparency = FALSE;
#ifdef HAVE_SN
	if (server.pids)
		g_tree_destroy(server.pids);
	server.pids = NULL;
#endif
}
Exemplo n.º 16
0
void
service_update_policies_destroy(struct service_update_policies_s *pol)
{
	GMutex *lock = NULL;

	if (!pol)
		return;

	if (pol->lock) {
		lock = pol->lock;
		pol->lock = NULL;
	}

	if (lock)
		g_mutex_lock(lock);

	if (pol->tree_elements) {
		g_tree_destroy(pol->tree_elements);
		pol->tree_elements = NULL;
	}

	if (lock) {
		g_mutex_unlock(lock);
		g_mutex_free(lock);
	}

	g_free(pol);
}
Exemplo n.º 17
0
void free_all() {
	gtk_widget_destroy(combo);
	g_object_unref(raster);
	g_key_file_free(settings);
	g_tree_destroy(pintable);
	g_sequence_free(dictionary);
}
Exemplo n.º 18
0
static void MailboxState_setMsginfo(T M, GTree *msginfo)
{
	GTree *oldmsginfo = M->msginfo;
	M->msginfo = msginfo;
	MailboxState_remap(M);
	if (oldmsginfo) g_tree_destroy(oldmsginfo);
}
Exemplo n.º 19
0
Arquivo: vtetc.c Projeto: Cordia/vte
static void
_vte_termcap_destroy (VteTermcap *termcap)
{
  g_tree_destroy (termcap->tree);
  g_mapped_file_free (termcap->file);
  g_slice_free (VteTermcap, termcap);
}
Exemplo n.º 20
0
enum filegetter_code service_filegetter_stop(service_filegetter_tp sfg) {
	assert(sfg);

	service_filegetter_log(sfg, SFG_INFO, "shutting down filegetter");

	enum filegetter_code result = FG_SUCCESS;

	if(sfg->think_times != NULL) {
		cdf_free(sfg->think_times);
		sfg->think_times = NULL;
	}

	if(sfg->downloads != NULL) {
		g_tree_destroy(sfg->downloads);
		sfg->downloads = NULL;
	}

	if(sfg->state != SFG_DONE) {
		result = filegetter_shutdown(&sfg->fg);
		sfg->current_download = NULL;
		sfg->state = SFG_DONE;
	}

	return result;
}
Exemplo n.º 21
0
int MailboxState_flush_recent(T M) 
{
	GList *recent;

	if ((!M) || (M && MailboxState_getPermission(M) != IMAPPERM_READWRITE))
		return DM_SUCCESS;

	if (! g_tree_nnodes(M->recent_queue))
		return DM_SUCCESS;

	TRACE(TRACE_DEBUG,"flush [%d] recent messages", g_tree_nnodes(M->recent_queue));

	recent = g_tree_keys(M->recent_queue);

	if (recent) {
		long long int changed = 0;
		uint64_t seq = MailboxState_getSeq(M);
		changed = _update_recent(g_list_slices_u64(recent,100), seq+1);
		if (changed)
			db_mailbox_seq_update(MailboxState_getId(M), 0);
	}

	g_list_free(g_list_first(recent));

	g_tree_foreach(M->recent_queue, (GTraverseFunc)_free_recent_queue, M);
	g_tree_destroy(M->recent_queue);
	M->recent_queue = g_tree_new((GCompareFunc)ucmp);

	return 0;
}
Exemplo n.º 22
0
int IDL_ns_check_for_ambiguous_inheritance (IDL_tree interface_ident, IDL_tree p)
{
	/* We use a sorted heap to check for namespace collisions,
	   since we must do case-insensitive collision checks.
	   visited_interfaces is a hash of visited interface nodes, so
	   we only visit common ancestors once. */
	GTree *ident_heap;
	GHashTable *visited_interfaces;
	int is_ambiguous = 0;

	if (!p)
		return 0;

	ident_heap = g_tree_new (IDL_ident_cmp);
	visited_interfaces = g_hash_table_new (g_direct_hash, g_direct_equal);

	assert (IDL_NODE_TYPE (p) == IDLN_LIST);
	for (; p;  p = IDL_LIST (p).next) {
		if (!IDL_ns_load_idents_to_tables (interface_ident, IDL_LIST (p).data,
						   ident_heap, visited_interfaces))
			is_ambiguous = 1;
	}

	g_tree_destroy (ident_heap);
	g_hash_table_destroy (visited_interfaces);

	return is_ambiguous;
}
Exemplo n.º 23
0
/* Completely destroys the defines tree */
static inline void
destroy_defines (GTree **defines)
{
    g_tree_traverse (*defines, mc_defines_destroy, G_POST_ORDER, NULL);
    g_tree_destroy (*defines);
    *defines = 0;
}
Exemplo n.º 24
0
void mlFreeModuleState(GTree *state)
{
    if(!state)
        return;

    g_tree_destroy(state);
}
Exemplo n.º 25
0
int main() {
	GTree *tokens;
	gboolean is_first = TRUE;
	gint i;

	tokens = g_tree_new((GCompareFunc)g_ascii_strcasecmp);

	for (i = 0; i < sql_token_get_last_id(); i++) {
		/** only tokens with TK_SQL_* are keyworks */
		if (0 != strncmp(sql_token_get_name(i, NULL), "TK_SQL_", sizeof("TK_SQL_") - 1)) continue;

		g_tree_insert(tokens, ( gpointer ) (sql_token_get_name(i, NULL) + sizeof("TK_SQL_") - 1), GINT_TO_POINTER(i));
	}

	/* traverse the tree and output all keywords in a sorted way */
	printf("static int sql_keywords[] = {");
	g_tree_foreach(tokens, trav, &is_first);
	printf("\n};\n");

	printf("int *sql_keywords_get() { return sql_keywords; }\n");
	printf("int sql_keywords_get_count() { return sizeof(sql_keywords) / sizeof(sql_keywords[0]); }\n");

	g_tree_destroy(tokens);

	return 0;
}
Exemplo n.º 26
0
Arquivo: syntax.c Projeto: artzub/mc
static void
destroy_defines (GTree ** defines)
{
    g_tree_foreach (*defines, mc_defines_destroy, NULL);
    g_tree_destroy (*defines);
    *defines = NULL;
}
Exemplo n.º 27
0
/** Free the root data structure and everything in it. */
void jpmidi_root_free( jpmidi_root_t* root)
{
    md_free(MD_ELEMENT(root->pmidi_root));
    /** FIXME - free the time and event data. */
    g_tree_destroy( root->data);
    g_free( root);

}
Exemplo n.º 28
0
/* closes the catalog, releasing all nodes */
void nodes_catalog_close(void)
{
  if (all_nodes)
  {
    g_tree_destroy(all_nodes);
    all_nodes = NULL;
  }
}
Exemplo n.º 29
0
/* closes the catalog, releasing all links */
void links_catalog_close(void)
{
  if (all_links)
  {
    g_tree_destroy(all_links);
    all_links = NULL;
  }
}
Exemplo n.º 30
0
static void
file_view_status_destroy (FileSymbolsStatus *fss)
{
	g_object_unref (fss->store);
	
	if (fss->nodes_displayed)
		g_tree_destroy (fss->nodes_displayed);
	
	/* free the waiting_for structs before destroying the tree itself */
	if (fss->waiting_for)
	{
		g_tree_foreach (fss->waiting_for, traverse_free_waiting_for, NULL);
		g_tree_destroy (fss->waiting_for);
	}	
	
	g_free (fss);
}