rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->results);
- new_task->re_cache = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
+ new_task->re_cache = g_hash_table_new (rspamd_regexp_hash, rspamd_regexp_equal);
rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->re_cache);
return re->ud;
}
-static gboolean
+gboolean
rspamd_regexp_equal (gconstpointer a, gconstpointer b)
{
const guchar *ia = a, *ib = b;
return (memcmp (ia, ib, sizeof (regexp_id_t)) == 0);
}
-static guint32
+guint32
rspamd_regexp_hash (gconstpointer a)
{
const guchar *ia = a;
*/
gpointer rspamd_regexp_get_ud (rspamd_regexp_t *re);
+/**
+ * Get regexp ID suitable for hashing
+ * @param re
+ * @return
+ */
+gpointer rspamd_regexp_get_id (rspamd_regexp_t *re);
+
/**
* Get pattern for the specified regexp object
* @param re
*/
void rspamd_regexp_cache_destroy (struct rspamd_regexp_cache *cache);
+/**
+ * Return the value for regexp hash based on its ID
+ * @param a
+ * @return
+ */
+guint32 rspamd_regexp_hash (gconstpointer a);
+
+/**
+ * Compare two regexp objects based on theirs ID
+ * @param a
+ * @param b
+ * @return
+ */
+gboolean rspamd_regexp_equal (gconstpointer a, gconstpointer b);
+
/**
* Initialize superglobal regexp cache and library
*/