diff options
author | chrisk%netscape.com <devnull@localhost> | 2000-06-21 18:12:02 +0000 |
---|---|---|
committer | chrisk%netscape.com <devnull@localhost> | 2000-06-21 18:12:02 +0000 |
commit | 8f711f322bf761764c22707c08752dc005df7ddf (patch) | |
tree | 419e894648418bac9c8331930c8db8b45c21ba0d | |
parent | c83b1120ec0709d7f9f8a483805e8c4fd0581ae7 (diff) | |
download | nss-hg-8f711f322bf761764c22707c08752dc005df7ddf.tar.gz |
Added some comments and asserts
-rw-r--r-- | security/nss/lib/smime/cmsarray.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/security/nss/lib/smime/cmsarray.c b/security/nss/lib/smime/cmsarray.c index 9ac16908d..68d7e1963 100644 --- a/security/nss/lib/smime/cmsarray.c +++ b/security/nss/lib/smime/cmsarray.c @@ -54,6 +54,8 @@ /* * NSS_CMSArray_Alloc - allocate an array in an arena + * + * This allocates space for the array of pointers */ void ** NSS_CMSArray_Alloc(PRArenaPool *poolp, int n) @@ -63,6 +65,8 @@ NSS_CMSArray_Alloc(PRArenaPool *poolp, int n) /* * NSS_CMSArray_Add - add an element to the end of an array + * + * The array of pointers is either created (if array was empty before) or grown. */ SECStatus NSS_CMSArray_Add(PRArenaPool *poolp, void ***array, void *obj) @@ -103,7 +107,7 @@ NSS_CMSArray_IsEmpty(void **array) } /* - * NSS_CMSArray_IsEmpty - count number of elements in array + * NSS_CMSArray_Count - count number of elements in array */ int NSS_CMSArray_Count(void **array) @@ -120,14 +124,16 @@ NSS_CMSArray_Count(void **array) } /* - * NSS_CMSArray_Sort - sort an array ascending, in place + * NSS_CMSArray_Sort - sort an array in place + * + * If "secondary" or "tertiary are not NULL, it must be arrays with the same + * number of elements as "primary". The same reordering will get applied to it. * - * If "secondary" is not NULL, the same reordering gets applied to it. - * If "tertiary" is not NULL, the same reordering gets applied to it. * "compare" is a function that returns * < 0 when the first element is less than the second * = 0 when the first element is equal to the second * > 0 when the first element is greater than the second + * to acheive ascending ordering. */ void NSS_CMSArray_Sort(void **primary, int (*compare)(void *,void *), void **secondary, void **tertiary) @@ -135,10 +141,11 @@ NSS_CMSArray_Sort(void **primary, int (*compare)(void *,void *), void **secondar int n, i, limit, lastxchg; void *tmp; - if (primary == NULL) - return; - n = NSS_CMSArray_Count(primary); + + PORT_Assert(secondary == NULL || NSS_CMSArray_Count(secondary) == n); + PORT_Assert(tertiary == NULL || NSS_CMSArray_Count(tertiary) == n); + if (n <= 1) /* ordering is fine */ return; |