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:
parent
7d560e9c18
commit
fd0b96ee9d
30
external/source/meterpreter/source/common/list.c
vendored
30
external/source/meterpreter/source/common/list.c
vendored
@ -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;
|
||||
}
|
@ -38,6 +38,8 @@ BOOL list_push( LIST * list, LPVOID data );
|
||||
|
||||
LPVOID list_pop( LIST * list );
|
||||
|
||||
LPVOID list_shift( LIST * list );
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user