Commit 3c914840 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

Move all the existing function pointer casts associated with LHASH's two

"doall" functions to using type-safe wrappers. As and where required, this
can be replaced by redeclaring the underlying callbacks to use the
underlying "void"-based prototypes (eg. if performance suffers from an
extra level of function invocation).
parent 98d517c5
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3,6 +3,11 @@

 Changes between 0.9.6 and 0.9.7  [xx XXX 2000]

  *) Finish off removing the remaining LHASH function pointer casts.
     There should no longer be any prototype-casting required when using
     the LHASH abstraction, and any casts that remain are "bugs".
     [Geoff Thorpe]

  *) Change the Unix RAND_poll() variant to be able to poll several
     random devices and only read data for a small fragment of time
     to avoid hangs.  Also separate out the Unix variant to it's own
+4 −3
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@
#include <stdio.h>
#include <openssl/conf.h>

void print_conf(CONF_VALUE *cv);
static void print_conf(CONF_VALUE *cv);
static IMPLEMENT_LHASH_DOALL_FN(print_conf, CONF_VALUE *);

main()
	{
@@ -73,11 +74,11 @@ main()
		exit(1);
		}

	lh_doall(conf,(LHASH_DOALL_FN_TYPE)print_conf);
	lh_doall(conf,LHASH_DOALL_FN(print_conf));
	}


void print_conf(CONF_VALUE *cv)
static void print_conf(CONF_VALUE *cv)
	{
	int i;
	CONF_VALUE *v;
+4 −2
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@

static void value_free_hash(CONF_VALUE *a, LHASH *conf);
static void value_free_stack(CONF_VALUE *a,LHASH *conf);
static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *)
static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *)
/* 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); */
@@ -198,13 +200,13 @@ void _CONF_free_data(CONF *conf)

	conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()'
				  * works as expected */
	lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)value_free_hash,
	lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash),
			conf->data);

	/* We now have only 'section' entries in the hash table.
	 * Due to problems with */

	lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)value_free_stack,
	lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack),
			conf->data);
	lh_free(conf->data);
	}
+3 −1
Original line number Diff line number Diff line
@@ -710,9 +710,11 @@ static void dump_value(CONF_VALUE *a, BIO *out)
		BIO_printf(out, "[[%s]]\n", a->section);
	}

static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *)

static int def_dump(CONF *conf, BIO *out)
	{
	lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)dump_value, out);
	lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out);
	return 1;
	}

+6 −2
Original line number Diff line number Diff line
@@ -248,6 +248,8 @@ static void do_all_fn(const OBJ_NAME *name,struct doall *d)
		d->fn(name,d->arg);
	}

static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *)

void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
	{
	struct doall d;
@@ -256,7 +258,7 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
	d.fn=fn;
	d.arg=arg;

	lh_doall_arg(names_lh,(LHASH_DOALL_ARG_FN_TYPE)do_all_fn,&d);
	lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d);
	}

struct doall_sorted
@@ -316,6 +318,8 @@ static void names_lh_free(OBJ_NAME *onp)
		}
	}

static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *)

static void name_funcs_free(NAME_FUNCS *ptr)
	{
	OPENSSL_free(ptr);
@@ -331,7 +335,7 @@ void OBJ_NAME_cleanup(int type)
	down_load=names_lh->down_load;
	names_lh->down_load=0;

	lh_doall(names_lh,(LHASH_DOALL_FN_TYPE)names_lh_free);
	lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free));
	if (type < 0)
		{
		lh_free(names_lh);
Loading