Commit 385d8138 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

First step in tidying up the LHASH code. The callback prototypes (and

casts) used in the lhash code are about as horrible and evil as they can
be. For starters, the callback prototypes contain empty parameter lists.
Yuck.

This first change defines clearer prototypes - including "typedef"'d
function pointer types to use as "hash" and "compare" callbacks, as well as
the callbacks passed to the lh_doall and lh_doall_arg iteration functions.
Now at least more explicit (and clear) casting is required in all of the
dependant code - and that should be included in this commit.

The next step will be to hunt down and obliterate some of the function
pointer casting being used when it's not necessary - a particularly evil
variant exists in the implementation of lh_doall.
parent 862e973b
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -753,15 +753,17 @@ bad:
		BIO_printf(bio_err,"generating index\n");
		}
	
	if (!TXT_DB_create_index(db,DB_serial,NULL,index_serial_hash,
		index_serial_cmp))
	if (!TXT_DB_create_index(db, DB_serial, NULL,
			(LHASH_HASH_FN_TYPE)index_serial_hash,
			(LHASH_COMP_FN_TYPE)index_serial_cmp))
		{
		BIO_printf(bio_err,"error creating serial number index:(%ld,%ld,%ld)\n",db->error,db->arg1,db->arg2);
		goto err;
		}

	if (!TXT_DB_create_index(db,DB_name,index_name_qual,index_name_hash,
		index_name_cmp))
	if (!TXT_DB_create_index(db, DB_name, index_name_qual,
			(LHASH_HASH_FN_TYPE)index_name_hash,
			(LHASH_COMP_FN_TYPE)index_name_cmp))
		{
		BIO_printf(bio_err,"error creating name index:(%ld,%ld,%ld)\n",
			db->error,db->arg1,db->arg2);
+3 −1
Original line number Diff line number Diff line
@@ -351,7 +351,9 @@ static LHASH *prog_init(void)
	    ;
	qsort(functions,i,sizeof *functions,SortFnByName);

	if ((ret=lh_new(hash,cmp)) == NULL) return(NULL);
	if ((ret=lh_new((LHASH_HASH_FN_TYPE)hash,
			(LHASH_COMP_FN_TYPE)cmp)) == NULL)
		return(NULL);

	for (f=functions; f->name != NULL; f++)
		lh_insert(ret,f);
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ main()
		exit(1);
		}

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


+6 −3
Original line number Diff line number Diff line
@@ -181,7 +181,8 @@ int _CONF_new_data(CONF *conf)
		return 0;
		}
	if (conf->data == NULL)
		if ((conf->data = lh_new(hash,cmp_conf)) == NULL)
		if ((conf->data = lh_new((LHASH_HASH_FN_TYPE)hash,
					(LHASH_COMP_FN_TYPE)cmp_conf)) == NULL)
			{
			return 0;
			}
@@ -194,12 +195,14 @@ 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,(void (*)())value_free_hash,conf->data);
	lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)value_free_hash,
			conf->data);

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

	lh_doall_arg(conf->data,(void (*)())value_free_stack,conf->data);
	lh_doall_arg(conf->data, (LHASH_DOALL_ARG_FN_TYPE)value_free_stack,
			conf->data);
	lh_free(conf->data);
	}

+1 −1
Original line number Diff line number Diff line
@@ -712,7 +712,7 @@ static void dump_value(CONF_VALUE *a, BIO *out)

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

Loading