removed some option functions
parent
4488ebaca6
commit
5c472203d7
|
@ -1,12 +1,6 @@
|
|||
|
||||
#include "options.h"
|
||||
|
||||
void options_init()
|
||||
{
|
||||
options = g_array_new(FALSE, TRUE, sizeof(option *));
|
||||
options_hash = g_hash_table_new((GHashFunc) g_int_hash, (GEqualFunc) g_int_equal);
|
||||
}
|
||||
|
||||
option* option_new_bool(gboolean val) {
|
||||
option *opt = g_slice_new0(option);
|
||||
opt->value.opt_bool = val;
|
||||
|
@ -125,40 +119,3 @@ gpointer option_extract_value(option *opt) {
|
|||
g_slice_free(option, opt);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean option_register(GString *name, option *opt) {
|
||||
guint *ndx;
|
||||
|
||||
ndx = g_slice_new(guint);
|
||||
|
||||
/* check if not already registered */
|
||||
if (option_index(name, ndx))
|
||||
return FALSE;
|
||||
|
||||
g_array_append_val(options, opt);
|
||||
*ndx = options->len;
|
||||
g_hash_table_insert(options_hash, (gpointer) name, (gpointer) ndx);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean option_unregister(GString *name) {
|
||||
UNUSED(name);
|
||||
assert(NULL == "does this even make sense?");
|
||||
}
|
||||
|
||||
|
||||
gboolean option_index(GString *name, guint *ndx) {
|
||||
guint *val;
|
||||
|
||||
val = (guint *) g_hash_table_lookup(options_hash, (gconstpointer) name);
|
||||
|
||||
if (val == NULL)
|
||||
return FALSE;
|
||||
|
||||
*ndx = *val;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,6 @@ typedef struct option_set option_set;
|
|||
|
||||
#include "base.h"
|
||||
|
||||
/* registered options */
|
||||
GArray *options;
|
||||
/* hash table to speed up lookup of options by name */
|
||||
GHashTable *options_hash;
|
||||
|
||||
struct option {
|
||||
option_type type;
|
||||
union {
|
||||
|
@ -51,14 +46,6 @@ LI_API option* option_new_list();
|
|||
LI_API option* option_new_hash();
|
||||
LI_API void option_free(option* opt);
|
||||
|
||||
|
||||
/* registers an option */
|
||||
LI_API gboolean option_register(GString *name, option *opt);
|
||||
/* unregisters an option */
|
||||
LI_API gboolean option_unregister(GString *name);
|
||||
/* retrieves the index of a previously registered option. returns TRUE if option was found, FALSE otherwise */
|
||||
LI_API gboolean option_index(GString *name, guint *index);
|
||||
|
||||
LI_API const char* option_type_string(option_type type);
|
||||
|
||||
LI_API void option_list_free(GArray *optlist);
|
||||
|
|
Loading…
Reference in New Issue