diff options
author | Geoff Thorpe <geoff@openssl.org> | 2000-12-08 20:02:01 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2000-12-08 20:02:01 +0000 |
commit | d0fa136ce22bb57638a1bf18e656602f53081ff3 (patch) | |
tree | b28c81ccdfe238a0e655b3ab906095a7589c133b /crypto/conf | |
parent | 15156cce0eed843d74ca06392144cad29c306ff7 (diff) |
Next step in tidying up the LHASH code.
DECLARE/IMPLEMENT macros now exist to create type (and prototype) safe
wrapper functions that avoid the use of function pointer casting yet retain
type-safety for type-specific callbacks. However, most of the usage within
OpenSSL itself doesn't really require the extra function because the hash
and compare callbacks are internal functions declared only for use by the
hash table. So this change catches all those cases and reimplements the
functions using the base-level LHASH prototypes and does per-variable
casting inside those functions to convert to the appropriate item type.
The exception so far is in ssl_lib.c where the hash and compare callbacks
are not static - they're exposed in ssl.h so their prototypes should not be
changed. In this last case, the IMPLEMENT_LHASH_*** macros have been left
intact.
Diffstat (limited to 'crypto/conf')
-rw-r--r-- | crypto/conf/conf_api.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c index 64bbd971ab..8216e64525 100644 --- a/crypto/conf/conf_api.c +++ b/crypto/conf/conf_api.c @@ -70,11 +70,12 @@ static void value_free_hash(CONF_VALUE *a, LHASH *conf); static void value_free_stack(CONF_VALUE *a,LHASH *conf); -static unsigned long hash(CONF_VALUE *v); -static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); - -static IMPLEMENT_LHASH_HASH_FN(hash, CONF_VALUE *) -static IMPLEMENT_LHASH_COMP_FN(cmp_conf, CONF_VALUE *) +/* We don't use function pointer casting or wrapper functions - but cast each + * callback parameter inside the callback functions. */ +/* static unsigned long hash(CONF_VALUE *v); */ +static unsigned long hash(void *v_void); +/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */ +static int cmp_conf(void *a_void,void *b_void); /* Up until OpenSSL 0.9.5a, this was get_section */ CONF_VALUE *_CONF_get_section(CONF *conf, char *section) @@ -184,8 +185,7 @@ int _CONF_new_data(CONF *conf) return 0; } if (conf->data == NULL) - if ((conf->data = lh_new(LHASH_HASH_FN(hash), - LHASH_COMP_FN(cmp_conf))) == NULL) + if ((conf->data = lh_new(hash, cmp_conf)) == NULL) { return 0; } @@ -238,14 +238,19 @@ static void value_free_stack(CONF_VALUE *a, LHASH *conf) OPENSSL_free(a); } -static unsigned long hash(CONF_VALUE *v) +/* static unsigned long hash(CONF_VALUE *v) */ +static unsigned long hash(void *v_void) { + CONF_VALUE *v = (CONF_VALUE *)v_void; return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); } -static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) +/* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */ +static int cmp_conf(void *a_void, void *b_void) { int i; + CONF_VALUE *a = (CONF_VALUE *)a_void; + CONF_VALUE *b = (CONF_VALUE *)b_void; if (a->section != b->section) { |