summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-10-22 15:43:01 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-10-22 15:43:01 +0000
commite19106f5fb7da7db15449a9a50f9be9047800757 (patch)
tree0341d860168821112fb47ded07b1f761895c04cd /crypto/asn1
parentae7ec4c71de74fa52c5d89e32e28445c6602990d (diff)
Create function of the form OBJ_bsearch_xxx() in bsearch typesafe macros
with the appropriate parameters which calls OBJ_bsearch(). A compiler will typically inline this. This avoids the need for cmp_xxx variables and fixes unchecked const issues with CHECKED_PTR_OF()
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/a_strnid.c10
-rw-r--r--crypto/asn1/ameth_lib.c10
2 files changed, 8 insertions, 12 deletions
diff --git a/crypto/asn1/a_strnid.c b/crypto/asn1/a_strnid.c
index f0d5416660..cdba943737 100644
--- a/crypto/asn1/a_strnid.c
+++ b/crypto/asn1/a_strnid.c
@@ -185,14 +185,14 @@ static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
return (*a)->nid - (*b)->nid;
}
-DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table_cmp);
+DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table);
static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b)
{
return a->nid - b->nid;
}
-IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table_cmp);
+IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table);
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
{
@@ -200,10 +200,8 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
ASN1_STRING_TABLE *ttmp;
ASN1_STRING_TABLE fnd;
fnd.nid = nid;
- ttmp = OBJ_bsearch(ASN1_STRING_TABLE, &fnd,
- ASN1_STRING_TABLE, tbl_standard,
- sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
- table_cmp);
+ ttmp = OBJ_bsearch_table(&fnd, tbl_standard,
+ sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE));
if(ttmp) return ttmp;
if(!stable) return NULL;
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c
index fee7198b85..5063191515 100644
--- a/crypto/asn1/ameth_lib.c
+++ b/crypto/asn1/ameth_lib.c
@@ -113,7 +113,7 @@ void main()
#endif
DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *,
- const EVP_PKEY_ASN1_METHOD *, ameth_cmp);
+ const EVP_PKEY_ASN1_METHOD *, ameth);
static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a,
const EVP_PKEY_ASN1_METHOD * const *b)
@@ -122,7 +122,7 @@ static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a,
}
IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *,
- const EVP_PKEY_ASN1_METHOD *, ameth_cmp);
+ const EVP_PKEY_ASN1_METHOD *, ameth);
int EVP_PKEY_asn1_get_count(void)
{
@@ -155,11 +155,9 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
if (idx >= 0)
return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
}
- ret = OBJ_bsearch(const EVP_PKEY_ASN1_METHOD *, &t,
- const EVP_PKEY_ASN1_METHOD *, standard_methods,
+ ret = OBJ_bsearch_ameth(&t, standard_methods,
sizeof(standard_methods)
- /sizeof(EVP_PKEY_ASN1_METHOD *),
- ameth_cmp);
+ /sizeof(EVP_PKEY_ASN1_METHOD *));
if (!ret || !*ret)
return NULL;
return *ret;