Пример #1
0
static int register_callback (llist_t **list, /* {{{ */
		const char *name, callback_func_t *cf)
{
	llentry_t *le;
	char *key;

	if (*list == NULL)
	{
		*list = llist_create ();
		if (*list == NULL)
		{
			ERROR ("plugin: register_callback: "
					"llist_create failed.");
			destroy_callback (cf);
			return (-1);
		}
	}

	key = strdup (name);
	if (key == NULL)
	{
		ERROR ("plugin: register_callback: strdup failed.");
		destroy_callback (cf);
		return (-1);
	}

	le = llist_search (*list, name);
	if (le == NULL)
	{
		le = llentry_create (key, cf);
		if (le == NULL)
		{
			ERROR ("plugin: register_callback: "
					"llentry_create failed.");
			free (key);
			destroy_callback (cf);
			return (-1);
		}

		llist_append (*list, le);
	}
	else
	{
		callback_func_t *old_cf;

		old_cf = le->value;
		le->value = cf;

		WARNING ("plugin: register_callback: "
				"a callback named `%s' already exists - "
				"overwriting the old entry!", name);

		destroy_callback (old_cf);
		sfree (key);
	}

	return (0);
} /* }}} int register_callback */
Пример #2
0
static void _destroy_keydata(struct ll_node *node, void *param)
{
	struct keydata_pair *kdp = (struct keydata_pair*)node->data;
	if(kdp) {
		void (*destroy_callback)(void *data) = (void (*)(void*))param;
		if(destroy_callback)
			destroy_callback(kdp->data);
		free(kdp);
	}
}
Пример #3
0
void CGrenade::net_Destroy() 
{
	if(m_destroy_callback)
	{
		m_destroy_callback				(this);
		m_destroy_callback				= destroy_callback(NULL);
	}

	inherited::net_Destroy				();
	CExplosive::net_Destroy				();
}
Пример #4
0
void CGrenade::Destroy() 
{
	//Generate Expode event
	Fvector						normal;

	if(m_destroy_callback)
	{
		m_destroy_callback		(this);
		m_destroy_callback	=	destroy_callback(NULL);
	}

	FindNormal					(normal);
	CExplosive::GenExplodeEvent	(Position(), normal);
}
Пример #5
0
static void _llist_destroy_content(struct linked_list* list, void (*destroy_callback)(struct ll_node *node, void *p), void *param)
{
	struct ll_node *current;
	struct ll_node *next;

	current = list->head;
	while(current) {
		next = current->next;
		if(destroy_callback)
			destroy_callback(current, param);
		free(current);
		current = next;
	}

}
Пример #6
0
static void destroy_read_heap (void) /* {{{ */
{
	if (read_heap == NULL)
		return;

	while (42)
	{
		callback_func_t *cf;

		cf = c_heap_get_root (read_heap);
		if (cf == NULL)
			break;

		destroy_callback (cf);
	}

	c_heap_destroy (read_heap);
	read_heap = NULL;
} /* }}} void destroy_read_heap */
Пример #7
0
static int plugin_unregister (llist_t *list, const char *name) /* {{{ */
{
	llentry_t *e;

	if (list == NULL)
		return (-1);

	e = llist_search (list, name);
	if (e == NULL)
		return (-1);

	llist_remove (list, e);

	sfree (e->key);
	destroy_callback (e->value);

	llentry_destroy (e);

	return (0);
} /* }}} int plugin_unregister */
Пример #8
0
void llist_remove(struct linked_list* list, struct ll_node* node, void (*destroy_callback)(struct ll_node *node, void *p), void *param)
{
	if(!list || !node)
		return;

	if(destroy_callback)
		destroy_callback(node, param);

	if(node->prev)
		node->prev->next = node->next;
	else
		list->head = node->next;

	if(node->next)
		node->next->prev = node->prev;
	else
		list->tail = node->prev;

#ifndef STRIPPED
	--list->elements;
#endif
	free(node);
}
Пример #9
0
static void destroy_all_callbacks (llist_t **list) /* {{{ */
{
	llentry_t *le;

	if (*list == NULL)
		return;

	le = llist_head (*list);
	while (le != NULL)
	{
		llentry_t *le_next;

		le_next = le->next;

		sfree (le->key);
		destroy_callback (le->value);
		le->value = NULL;

		le = le_next;
	}

	llist_destroy (*list);
	*list = NULL;
} /* }}} void destroy_all_callbacks */
Пример #10
0
static void ok_callback(GtkWidget *widget, GtkWidget *nothing)
{
install_proc_filter(GLOBALS->current_filter_ptranslate_c_1);
destroy_callback(widget, nothing);
}