Cleaned up usage of linked lists and added missing functionality.
- Added a list_remove_first() which is generally better than list_remove() provided you want to remove the first element. - Added a list_append_list() to append and move all nodes from one list to another.
This commit is contained in:
@@ -90,16 +90,10 @@ int event_queue_process(struct event_queue* queue)
|
||||
|
||||
/* unlock queue */
|
||||
queue->locked = 0;
|
||||
|
||||
|
||||
/* transfer from secondary queue to the primary queue. */
|
||||
data = (struct event_data*) list_get_first(queue->q2);
|
||||
while (data)
|
||||
{
|
||||
list_remove(queue->q2, data);
|
||||
list_append(queue->q1, data);
|
||||
data = (struct event_data*) list_get_first(queue->q2);
|
||||
}
|
||||
|
||||
list_append_list(queue->q1, queue->q2);
|
||||
|
||||
/* if more events exist, schedule it */
|
||||
if (list_size(queue->q1))
|
||||
{
|
||||
|
||||
@@ -1320,9 +1320,7 @@ void hub_logout_log(struct hub_info* hub, struct hub_user* user)
|
||||
list_append(hub->logout_info, loginfo);
|
||||
while (list_size(hub->logout_info) > (size_t) hub->config->max_logout_log)
|
||||
{
|
||||
struct hub_logout_info* entry = list_get_first(hub->logout_info);
|
||||
list_remove(hub->logout_info, entry);
|
||||
hub_free(entry);
|
||||
list_remove_first(hub->logout_info, hub_free);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,16 +229,16 @@ int plugin_initialize(struct hub_config* config, struct hub_info* hub)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void plugin_unload_ptr(void* ptr)
|
||||
{
|
||||
struct plugin_handle* plugin = (struct plugin_handle*) ptr;
|
||||
plugin_unload(plugin);
|
||||
}
|
||||
|
||||
|
||||
void plugin_shutdown(struct uhub_plugins* handle)
|
||||
{
|
||||
struct plugin_handle* plugin = (struct plugin_handle*) list_get_first(handle->loaded);
|
||||
while (plugin)
|
||||
{
|
||||
list_remove(handle->loaded, plugin);
|
||||
plugin_unload(plugin);
|
||||
plugin = (struct plugin_handle*) list_get_first(handle->loaded);
|
||||
}
|
||||
|
||||
list_clear(handle->loaded, plugin_unload_ptr);
|
||||
list_destroy(handle->loaded);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user