diff options
author | mcgreer%netscape.com <devnull@localhost> | 2001-09-19 20:20:06 +0000 |
---|---|---|
committer | mcgreer%netscape.com <devnull@localhost> | 2001-09-19 20:20:06 +0000 |
commit | e7f4da4c84839a6cd5e3e6b1d0e9665b8e933a17 (patch) | |
tree | b4320b7e98c7d932a5c39a98f7c5d9e3e71adde4 /security/nss/lib/base/base.h | |
parent | a26f4f92d38df6a1c1bb633848d6f72a781aa4f2 (diff) | |
download | nss-hg-e7f4da4c84839a6cd5e3e6b1d0e9665b8e933a17.tar.gz |
initial checkin of threadsafe list
Diffstat (limited to 'security/nss/lib/base/base.h')
-rw-r--r-- | security/nss/lib/base/base.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/security/nss/lib/base/base.h b/security/nss/lib/base/base.h index 4206cb542..1a3054b73 100644 --- a/security/nss/lib/base/base.h +++ b/security/nss/lib/base/base.h @@ -768,6 +768,172 @@ nssUTF8_Equal ); /* + * nssList + * + * The goal is to provide a simple, optionally threadsafe, linked list + * class. Since NSS did not seem to use the circularity of PRCList + * much before, this provides a list that appears to be a linear, + * NULL-terminated list. + */ + +/* + * nssList_Create + * + * If threadsafe is true, the list will be locked during modifications + * and traversals. + */ +NSS_EXTERN nssList * +nssList_Create +( + PRBool threadSafe +); + +/* + * nssList_Destroy + */ +NSS_EXTERN PRStatus +nssList_Destroy +( + nssList *list +); + +/* + * nssList_SetCompareFunction + * + * By default, two list elements will be compared by comparing their + * data pointers. By setting this function, the user can control + * how elements are compared. + */ +NSS_EXTERN void +nssList_SetCompareFunction +( + nssList *list, + nssListCompareFunc compareFunc +); + +/* + * nssList_AddElement + */ +NSS_EXTERN PRStatus +nssList_AddElement +( + nssList *list, + void *data +); + +/* + * nssList_AddElementUnique + * + * This will use the compare function to see if the element is already + * in the list. + */ +NSS_EXTERN PRStatus +nssList_AddElementUnique +( + nssList *list, + void *data +); + +/* + * nssList_RemoveElement + * + * Uses the compare function to locate the element and remove it. + */ +NSS_EXTERN PRStatus +nssList_RemoveElement(nssList *list, void *data); + +/* + * nssList_GetElement + * + * Uses the compare function to locate an element. Also serves as + * nssList_Exists. + */ +NSS_EXTERN void * +nssList_GetElement +( + nssList *list, + void *data +); + +/* + * nssList_GetNumElements + */ +NSS_EXTERN PRUint32 +nssList_GetNumElements +( + nssList *list +); + +/* + * nssList_GetArray + * + * Fill rvArray, up to maxElements, with elements in the list. The + * array is NULL-terminated, so its allocated size must be maxElements + 1. + */ +NSS_EXTERN PRStatus +nssList_GetArray +( + nssList *list, + void **rvArray, + PRUint32 maxElements +); + +/* + * nssList_CreateIterator + * + * Create an iterator for list traversal. + */ +NSS_EXTERN nssListIterator * +nssList_CreateIterator +( + nssList *list +); + +/* + * nssListIterator_Destroy + */ +NSS_EXTERN void +nssListIterator_Destroy +( + nssListIterator *iter +); + +/* + * nssListIterator_Start + * + * Begin a list iteration. After this call, if the list is threadSafe, + * the list is *locked*. + */ +NSS_EXTERN void * +nssListIterator_Start +( + nssListIterator *iter +); + +/* + * nssListIterator_Next + * + * Continue a list iteration. + */ +NSS_EXTERN void * +nssListIterator_Next +( + nssListIterator *iter +); + +/* + * nssListIterator_Finish + * + * Complete a list iteration. This *must* be called in order for the + * lock to be released. + */ +NSS_EXTERN PRStatus +nssListIterator_Finish +( + nssListIterator *iter +); + +/* * nssPointerTracker * * This type and these methods are only present in debug builds. |