1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00

Add a list_shift() function to the common linked list code.

git-svn-id: file:///home/svn/framework3/trunk@10052 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Stephen Fewer 2010-08-19 11:25:11 +00:00
parent 7d560e9c18
commit fd0b96ee9d
2 changed files with 29 additions and 3 deletions

View File

@ -2,9 +2,9 @@
/*
* An implementation of a simple thread safe double linked list structure. Can be used as either
* a stack (via pop/push) or an array (via get/add/insert/remove). If performing a group of
* actions on a list based on results from list actions, acquire the list lock before the group
* of actions and release lock when done.
* a stack (via pop/push), a queue (via push/shift) or an array (via get/add/insert/remove). If
* performing a group of actions on a list based on results from list actions, acquire the list
* lock before the group of actions and release lock when done.
*/
/*
@ -310,3 +310,27 @@ LPVOID list_pop( LIST * list )
return data;
}
/*
* Pop a data value off the start of the list.
*/
LPVOID list_shift( LIST * list )
{
LPVOID data = NULL;
if( list == NULL )
return NULL;
lock_acquire( list->lock );
if( list->start != NULL )
{
data = list->start->data;
list_remove_node( list, list->start );
}
lock_release( list->lock );
return data;
}

View File

@ -38,6 +38,8 @@ BOOL list_push( LIST * list, LPVOID data );
LPVOID list_pop( LIST * list );
LPVOID list_shift( LIST * list );
/*****************************************************************************************/
#endif