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