mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-04-06 01:16:37 +02: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
197a5684a2
commit
a635b67ada
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* An implementation of a simple thread safe double linked list structure. Can be used as either
|
* 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
|
* a stack (via pop/push), a queue (via push/shift) or an array (via get/add/insert/remove). If
|
||||||
* actions on a list based on results from list actions, acquire the list lock before the group
|
* performing a group of actions on a list based on results from list actions, acquire the list
|
||||||
* of actions and release lock when done.
|
* lock before the group of actions and release lock when done.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -308,5 +308,29 @@ LPVOID list_pop( LIST * list )
|
|||||||
|
|
||||||
lock_release( list->lock );
|
lock_release( list->lock );
|
||||||
|
|
||||||
|
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;
|
return data;
|
||||||
}
|
}
|
@ -38,6 +38,8 @@ BOOL list_push( LIST * list, LPVOID data );
|
|||||||
|
|
||||||
LPVOID list_pop( LIST * list );
|
LPVOID list_pop( LIST * list );
|
||||||
|
|
||||||
|
LPVOID list_shift( LIST * list );
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user