Example #1
0
void nx_config_cache_free()
{
    nx_ctx_t *ctx;
    nx_cc_item_t *item = NULL;
    apr_hash_index_t *idx;
    const char *key;
    apr_ssize_t keylen;

    ctx = nx_ctx_get();

    CHECKERR(apr_thread_mutex_lock(ctx->config_cache_mutex));
    for ( idx = apr_hash_first(NULL, ctx->config_cache);
	  idx != NULL;
	  idx = apr_hash_next(idx) )
    {
	apr_hash_this(idx, (const void **) &key, &keylen, (void **) &item);
	apr_hash_set(ctx->config_cache, item->key, APR_HASH_KEY_STRING, NULL);
	_free_item(item);
    }
    if ( ctx->ccfile != NULL )
    {
	apr_file_close(ctx->ccfile);
	ctx->ccfile = NULL;
    }
    CHECKERR(apr_thread_mutex_unlock(ctx->config_cache_mutex));
}
static void stop (void)
{
	if (s_cBookmarksFile == NULL)
		return ;
	
	cairo_dock_fm_remove_monitor_full (s_cBookmarksFile, FALSE, NULL);
	g_free (s_cBookmarksFile);
	s_cBookmarksFile = NULL;
	_free_item (s_pRootItem);
	s_pRootItem = NULL;
}
void cd_quick_browser_destroy_menu (GldiModuleInstance *myApplet)
{
	if (myData.iSidFillDirIdle != 0)
		g_source_remove (myData.iSidFillDirIdle);
	myData.iSidFillDirIdle = 0;
	
	if (myData.pRootItem != NULL)
	{
		gtk_widget_destroy (myData.pRootItem->pSubMenu);  // detruit tous les pSubMenu en cascade.
		_free_item (myData.pRootItem);
		myData.pRootItem = NULL;
	}
}
Example #4
0
void cd_rssreader_free_item_list (GldiModuleInstance *myApplet)
{
    if (myData.pItemList == NULL)
        return;
    CDRssItem *pItem;
    GList *it;
    for (it = myData.pItemList; it != NULL; it = it->next)
    {
        pItem = it->data;
        _free_item (pItem);
    }
    g_list_free (myData.pItemList);
    myData.pItemList = NULL;
    myData.iFirstDisplayedItem = 0;

    gldi_object_unref (GLDI_OBJECT(myData.pDialog));  // un peu bourrin mais bon ... on pourrait le reafficher s'il etait present ...
    myData.pDialog = NULL;
}
Example #5
0
static void _read_item(char * volatile buf,
		       apr_size_t volatile bufsize,
		       apr_hash_t *cache,
		       apr_size_t *bytesread)
{
    nx_cc_item_t *item = NULL;
    nx_cc_item_t *tmpitem = NULL;
    nx_value_t * volatile key = NULL;
    nx_value_t *value = NULL;
    apr_size_t readsize;
    nx_exception_t e;

    ASSERT(buf != NULL);
    ASSERT(cache != NULL);

    item = malloc(sizeof(nx_cc_item_t));
    memset(item, 0, sizeof(nx_cc_item_t));

    try
    {
	key = nx_value_from_membuf(buf, bufsize, &readsize);
	if ( (key == NULL) || (key->type != NX_VALUE_TYPE_STRING) )
	{
	    throw_msg("failed to read key from config cache");
	}
	buf = buf + readsize;
	*bytesread = readsize;
	bufsize -= readsize;
	item->key = strdup(key->string->buf);
	nx_value_free(key);
	key = NULL;

	value = nx_value_from_membuf(buf, bufsize, &readsize);
	if ( value == NULL )
	{
	    throw_msg("failed to read value from config cache");
	}
	item->value = value;

	if ( item->value->type == NX_VALUE_TYPE_INTEGER )
	{
	    log_debug("read config cache item: %s=%ld", item->key, item->value->integer);
	}
	else if ( item->value->type == NX_VALUE_TYPE_STRING )
	{
	    log_debug("read config cache item: %s=%s", item->key, item->value->string->buf);
	}
	else
	{
	    log_debug("read config cache item: %s", item->key);
	}

	*bytesread += readsize;
    }
    catch(e)
    {
	if ( item != NULL )
	{
	    _free_item(item);
	}
	if ( key != NULL )
	{
	    nx_value_free(key);
	}
	if ( value != NULL )
	{
	    nx_value_free(value);
	}
	rethrow(e);
    }

    tmpitem = (nx_cc_item_t *) apr_hash_get(cache, item->key, APR_HASH_KEY_STRING);
    ASSERT(tmpitem == NULL);
    apr_hash_set(cache, item->key, APR_HASH_KEY_STRING, (void *) item);
}