diff options
Diffstat (limited to 'src/lib/libcrypto/stack/stack.c')
-rw-r--r-- | src/lib/libcrypto/stack/stack.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c index c7173eb6ab..378bd7c796 100644 --- a/src/lib/libcrypto/stack/stack.c +++ b/src/lib/libcrypto/stack/stack.c | |||
@@ -68,11 +68,12 @@ | |||
68 | #include <stdio.h> | 68 | #include <stdio.h> |
69 | #include "cryptlib.h" | 69 | #include "cryptlib.h" |
70 | #include <openssl/stack.h> | 70 | #include <openssl/stack.h> |
71 | #include <openssl/objects.h> | ||
71 | 72 | ||
72 | #undef MIN_NODES | 73 | #undef MIN_NODES |
73 | #define MIN_NODES 4 | 74 | #define MIN_NODES 4 |
74 | 75 | ||
75 | const char *STACK_version="Stack" OPENSSL_VERSION_PTEXT; | 76 | const char STACK_version[]="Stack" OPENSSL_VERSION_PTEXT; |
76 | 77 | ||
77 | #include <errno.h> | 78 | #include <errno.h> |
78 | 79 | ||
@@ -209,7 +210,7 @@ char *sk_delete(STACK *st, int loc) | |||
209 | return(ret); | 210 | return(ret); |
210 | } | 211 | } |
211 | 212 | ||
212 | int sk_find(STACK *st, char *data) | 213 | static int internal_find(STACK *st, char *data, int ret_val_options) |
213 | { | 214 | { |
214 | char **r; | 215 | char **r; |
215 | int i; | 216 | int i; |
@@ -232,19 +233,19 @@ int sk_find(STACK *st, char *data) | |||
232 | * not (type *) pointers, but the *pointers* to (type *) pointers, | 233 | * not (type *) pointers, but the *pointers* to (type *) pointers, |
233 | * so we get our extra level of pointer dereferencing that way. */ | 234 | * so we get our extra level of pointer dereferencing that way. */ |
234 | comp_func=(int (*)(const void *,const void *))(st->comp); | 235 | comp_func=(int (*)(const void *,const void *))(st->comp); |
235 | r=(char **)bsearch(&data,(char *)st->data, | 236 | r=(char **)OBJ_bsearch_ex((char *)&data,(char *)st->data, |
236 | st->num,sizeof(char *), comp_func); | 237 | st->num,sizeof(char *),comp_func,ret_val_options); |
237 | if (r == NULL) return(-1); | 238 | if (r == NULL) return(-1); |
238 | i=(int)(r-st->data); | 239 | return((int)(r-st->data)); |
239 | for ( ; i>0; i--) | 240 | } |
240 | /* This needs a cast because the type being pointed to from | 241 | |
241 | * the "&" expressions are (char *) rather than (const char *). | 242 | int sk_find(STACK *st, char *data) |
242 | * For an explanation, read: | 243 | { |
243 | * http://www.eskimo.com/~scs/C-faq/q11.10.html :-) */ | 244 | return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH); |
244 | if ((*st->comp)((const char * const *)&(st->data[i-1]), | 245 | } |
245 | (const char * const *)&data) < 0) | 246 | int sk_find_ex(STACK *st, char *data) |
246 | break; | 247 | { |
247 | return(i); | 248 | return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH); |
248 | } | 249 | } |
249 | 250 | ||
250 | int sk_push(STACK *st, char *data) | 251 | int sk_push(STACK *st, char *data) |