diff options
author | Richard Levitte <levitte@openssl.org> | 2019-05-08 10:40:20 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-05-08 16:17:16 +0200 |
commit | 5c3f1e34b559c9b4372bf48aab63b61a6cd5edbb (patch) | |
tree | 3c6d91959d546794e32517dd5adecc8f1bbc0333 /crypto/stack | |
parent | 67c81ec311d696464bdbf4c6d6f8a887a3ddf9f8 (diff) |
ossl_bsearch(): New generic internal binary search utility function
OBJ_bsearch_ and OBJ_bsearch_ex_ are generic functions that don't
really belong with the OBJ API, but should rather be generic utility
functions. The ending underscore indicates that they are considered
internal, even though they are declared publicly.
Since crypto/stack/stack.c uses OBJ_bsearch_ex_, the stack API ends up
depending on the OBJ API, which is unnecessary, and carries along
other dependencies.
Therefor, a generic internal function is created, ossl_bsearch().
This removes the unecessary dependencies.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8899)
Diffstat (limited to 'crypto/stack')
-rw-r--r-- | crypto/stack/stack.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index 2f0ed64232..450a4e1a0e 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -11,7 +11,6 @@ #include "internal/cryptlib.h" #include "internal/numbers.h" #include <openssl/stack.h> -#include <openssl/objects.h> #include <errno.h> #include <openssl/e_os2.h> /* For ossl_inline */ @@ -307,20 +306,20 @@ static int internal_find(OPENSSL_STACK *st, const void *data, } if (data == NULL) return -1; - r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp, - ret_val_options); + r = ossl_bsearch(&data, st->data, st->num, sizeof(void *), st->comp, + ret_val_options); return r == NULL ? -1 : (int)((const void **)r - st->data); } int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data) { - return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH); + return internal_find(st, data, OSSL_BSEARCH_FIRST_VALUE_ON_MATCH); } int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data) { - return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH); + return internal_find(st, data, OSSL_BSEARCH_VALUE_ON_NOMATCH); } int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data) |