From: Pauli Date: Wed, 15 Mar 2017 04:29:08 +0000 (+1000) Subject: Rewrite the documentation for sk_TYPE_find() and sk_TYPE_find_ex() to better X-Git-Tag: OpenSSL_1_1_1-pre1~2029 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=89b06ca7b0b08d31ac48275d1376a7046dd75f55;p=oweals%2Fopenssl.git Rewrite the documentation for sk_TYPE_find() and sk_TYPE_find_ex() to better describe the vagaries in their behaviour. [skip ci] Reviewed-by: Richard Levitte Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/2958) --- diff --git a/doc/man3/DEFINE_STACK_OF.pod b/doc/man3/DEFINE_STACK_OF.pod index af8dd09ff3..e6684f8009 100644 --- a/doc/man3/DEFINE_STACK_OF.pod +++ b/doc/man3/DEFINE_STACK_OF.pod @@ -140,14 +140,22 @@ sk_TYPE_set() sets element B of B to B replacing the current element. The new element value is returned or B if an error occurred: this will only happen if B is B or B is out of range. -sk_TYPE_find() and sk_TYPE_find_ex() search B using the supplied -comparison function for an element matching B. sk_TYPE_find() returns -the index of the first matching element or B<-1> if there is no match. -sk_TYPE_find_ex() returns a matching element or the nearest element that -does not match B. Note: if a comparison function is set then B is -sorted before the search which may change its order. If no comparison -function is set then a linear search is made for a pointer matching B -and the stack is not reordered. +sk_TYPE_find() searches B for the element B. In the case +where no comparison function has been specified, the function performs +a linear search for a pointer equal to B. The index of the first +matching element is returned or B<-1> if there is no match. In the case +where a comparison function has been specified, B is sorted then +sk_TYPE_find() returns the index of a matching element or B<-1> if there +is no match. Note that, in this case, the matching element returned is +not guaranteed to be the first; the comparison function will usually +compare the values pointed to rather than the pointers themselves and +the order of elements in B could change. + +sk_TYPE_find_ex() operates like sk_TYPE_find() except when a comparison +function has been specified and no matching element is found. Instead +of returning B<-1>, sk_TYPE_find_ex() returns the index of the element +either before or after the location where B would be if it were +present in B. sk_TYPE_sort() sorts B using the supplied comparison function.