*/
#define DICTIONARY_FOREACH(element, state, dict) for (irc_dictionary_foreach_start((dict), (state)); (element = irc_dictionary_foreach_cur((dict), (state))); irc_dictionary_foreach_next((dict), (state)))
-/*
- * irc_dictionary_create() creates a new dictionary tree.
- * compare_cb is the comparison function, typically strcmp, strcasecmp or
- * irccasecmp.
- */
-extern struct Dictionary *irc_dictionary_create(DCF compare_cb);
-
/*
* irc_dictionary_create_named() creates a new dictionary tree which has a name.
* name is the name, compare_cb is the comparator.
*/
-extern struct Dictionary *irc_dictionary_create_named(const char *name, DCF compare_cb);
+extern struct Dictionary *irc_dictionary_create(const char *name, DCF compare_cb);
/*
* irc_dictionary_set_comparator_func() resets the comparator used for lookups and
oper_motd = cache_file(OPATH, "opers.motd", 0);
memset(&links_cache_list, 0, sizeof(links_cache_list));
- help_dict_oper = irc_dictionary_create(strcasecmp);
- help_dict_user = irc_dictionary_create(strcasecmp);
+ help_dict_oper = irc_dictionary_create("oper help", strcasecmp);
+ help_dict_user = irc_dictionary_create("user help", strcasecmp);
}
/*
idx = rb_malloc(sizeof(struct CapabilityIndex));
idx->name = rb_strdup(name);
- idx->cap_dict = irc_dictionary_create(strcasecmp);
+ idx->cap_dict = irc_dictionary_create(name, strcasecmp);
idx->highest_bit = 1;
rb_dlinkAdd(idx, &idx->node, &capability_indexes);
rb_event_addish("exit_aborted_clients", exit_aborted_clients, NULL, 1);
rb_event_add("flood_recalc", flood_recalc, NULL, 1);
- nd_dict = irc_dictionary_create(irccmp);
+ nd_dict = irc_dictionary_create("nickdelay", irccmp);
}
#include "s_assert.h"
#include "logger.h"
-static rb_bh *elem_heap = NULL;
-
struct Dictionary
{
DCF compare_cb;
};
/*
- * irc_dictionary_create(DCF compare_cb)
- *
- * Dictionary object factory.
- *
- * Inputs:
- * - function to use for comparing two entries in the dtree
- *
- * Outputs:
- * - on success, a new dictionary object.
- *
- * Side Effects:
- * - if services runs out of memory and cannot allocate the object,
- * the program will abort.
- */
-struct Dictionary *irc_dictionary_create(DCF compare_cb)
-{
- struct Dictionary *dtree = (struct Dictionary *) rb_malloc(sizeof(struct Dictionary));
-
- dtree->compare_cb = compare_cb;
-
- if (!elem_heap)
- elem_heap = rb_bh_create(sizeof(struct DictionaryElement), 1024, "dictionary_elem_heap");
-
- return dtree;
-}
-
-/*
- * irc_dictionary_create_named(const char *name,
- * DCF compare_cb)
+ * irc_dictionary_create(const char *name, DCF compare_cb)
*
* Dictionary object factory.
*
* - if services runs out of memory and cannot allocate the object,
* the program will abort.
*/
-struct Dictionary *irc_dictionary_create_named(const char *name,
+struct Dictionary *irc_dictionary_create(const char *name,
DCF compare_cb)
{
struct Dictionary *dtree = (struct Dictionary *) rb_malloc(sizeof(struct Dictionary));
dtree->compare_cb = compare_cb;
dtree->id = rb_strdup(name);
- if (!elem_heap)
- elem_heap = rb_bh_create(sizeof(struct DictionaryElement), 1024, "dictionary_elem_heap");
-
return dtree;
}
dict->root->data = delem->data;
dict->count--;
- rb_bh_free(elem_heap, delem);
+ rb_free(delem);
}
}
}
if (destroy_cb != NULL)
(*destroy_cb)(n, privdata);
- rb_bh_free(elem_heap, n);
+ rb_free(n);
}
rb_free(dtree);
s_assert(data != NULL);
s_assert(irc_dictionary_find(dict, key) == NULL);
- delem = rb_bh_alloc(elem_heap);
+ delem = rb_malloc(sizeof(*delem));
delem->key = key;
delem->data = data;
/* TBD: is this needed? --nenolod */
if (delem->key == NULL)
{
- rb_bh_free(elem_heap, delem);
+ rb_free(delem);
return NULL;
}
data = delem->data;
irc_dictionary_unlink_root(dtree);
- rb_bh_free(elem_heap, delem);
+ rb_free(delem);
return data;
}
void
clear_hash_parse()
{
- cmd_dict = irc_dictionary_create(strcasecmp);
+ cmd_dict = irc_dictionary_create("command", strcasecmp);
}
/* mod_add_cmd
ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA1;
if (!alias_dict)
- alias_dict = irc_dictionary_create(strcasecmp);
+ alias_dict = irc_dictionary_create("alias", strcasecmp);
}
#undef YES
#include "hash.h"
#include "reject.h"
#include "whowas.h"
+#include "irc_radixtree.h"
static int m_stats (struct Client *, struct Client *, int, const char **);