aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/shingles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/shingles.c')
-rw-r--r--src/libutil/shingles.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c
index f074c76ff..5fe110eb8 100644
--- a/src/libutil/shingles.c
+++ b/src/libutil/shingles.c
@@ -22,7 +22,7 @@
#define SHINGLES_WINDOW 3
#define SHINGLES_KEY_SIZE rspamd_cryptobox_SIPKEYBYTES
-static guint
+static unsigned int
rspamd_shingles_keys_hash(gconstpointer k)
{
return rspamd_cryptobox_fast_hash(k, SHINGLES_KEY_SIZE,
@@ -38,8 +38,8 @@ rspamd_shingles_keys_equal(gconstpointer k1, gconstpointer k2)
static void
rspamd_shingles_keys_free(gpointer p)
{
- guchar **k = p;
- guint i;
+ unsigned char **k = p;
+ unsigned int i;
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
g_free(k[i]);
@@ -48,30 +48,30 @@ rspamd_shingles_keys_free(gpointer p)
g_free(k);
}
-static guchar **
+static unsigned char **
rspamd_shingles_keys_new(void)
{
- guchar **k;
- guint i;
+ unsigned char **k;
+ unsigned int i;
- k = g_malloc0(sizeof(guchar *) * RSPAMD_SHINGLE_SIZE);
+ k = g_malloc0(sizeof(unsigned char *) * RSPAMD_SHINGLE_SIZE);
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
- k[i] = g_malloc0(sizeof(guchar) * SHINGLES_KEY_SIZE);
+ k[i] = g_malloc0(sizeof(unsigned char) * SHINGLES_KEY_SIZE);
}
return k;
}
-static guchar **
-rspamd_shingles_get_keys_cached(const guchar key[SHINGLES_KEY_SIZE])
+static unsigned char **
+rspamd_shingles_get_keys_cached(const unsigned char key[SHINGLES_KEY_SIZE])
{
static GHashTable *ht = NULL;
- guchar **keys = NULL, *key_cpy;
+ unsigned char **keys = NULL, *key_cpy;
rspamd_cryptobox_hash_state_t bs;
- const guchar *cur_key;
- guchar shabuf[rspamd_cryptobox_HASHBYTES], *out_key;
- guint i;
+ const unsigned char *cur_key;
+ unsigned char shabuf[rspamd_cryptobox_HASHBYTES], *out_key;
+ unsigned int i;
if (ht == NULL) {
ht = g_hash_table_new_full(rspamd_shingles_keys_hash,
@@ -113,7 +113,7 @@ rspamd_shingles_get_keys_cached(const guchar key[SHINGLES_KEY_SIZE])
struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
rspamd_shingles_from_text(GArray *input,
- const guchar key[16],
+ const unsigned char key[16],
rspamd_mempool_t *pool,
rspamd_shingles_filter filter,
gpointer filterd,
@@ -121,11 +121,11 @@ struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
{
struct rspamd_shingle *res;
uint64_t **hashes;
- guchar **keys;
+ unsigned char **keys;
rspamd_fstring_t *row;
rspamd_stat_token_t *word;
uint64_t val;
- gint i, j, k;
+ int i, j, k;
gsize hlen, ilen = 0, beg = 0, widx = 0;
enum rspamd_cryptobox_fast_hash_type ht;
@@ -157,8 +157,8 @@ struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
/* Now parse input words into a vector of hashes using rolling window */
if (alg == RSPAMD_SHINGLES_OLD) {
- for (i = 0; i <= (gint) ilen; i++) {
- if (i - beg >= SHINGLES_WINDOW || i == (gint) ilen) {
+ for (i = 0; i <= (int) ilen; i++) {
+ if (i - beg >= SHINGLES_WINDOW || i == (int) ilen) {
for (j = beg; j < i; j++) {
word = NULL;
@@ -196,7 +196,7 @@ struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
/* Now we need to create a new row here */
for (j = 0; j < RSPAMD_SHINGLE_SIZE; j++) {
- rspamd_cryptobox_siphash((guchar *) &val, row->str, row->len,
+ rspamd_cryptobox_siphash((unsigned char *) &val, row->str, row->len,
keys[j]);
g_assert(hlen > beg);
hashes[j][beg] = val;
@@ -301,8 +301,8 @@ struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
}
struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
- rspamd_shingles_from_image(guchar *dct,
- const guchar key[16],
+ rspamd_shingles_from_image(unsigned char *dct,
+ const unsigned char key[16],
rspamd_mempool_t *pool,
rspamd_shingles_filter filter,
gpointer filterd,
@@ -310,10 +310,10 @@ struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
{
struct rspamd_shingle *shingle;
uint64_t **hashes;
- guchar **keys;
+ unsigned char **keys;
uint64_t d;
uint64_t val;
- gint i, j;
+ int i, j;
gsize hlen, beg = 0;
enum rspamd_cryptobox_fast_hash_type ht;
uint64_t res[SHINGLES_WINDOW * RSPAMD_SHINGLE_SIZE], seed;
@@ -382,7 +382,7 @@ struct rspamd_shingle *RSPAMD_OPTIMIZE("unroll-loops")
uint64_t
rspamd_shingles_default_filter(uint64_t *input, gsize count,
- gint shno, const guchar *key, gpointer ud)
+ int shno, const unsigned char *key, gpointer ud)
{
uint64_t minimal = G_MAXUINT64;
gsize i;
@@ -397,10 +397,10 @@ rspamd_shingles_default_filter(uint64_t *input, gsize count,
}
-gdouble rspamd_shingles_compare(const struct rspamd_shingle *a,
- const struct rspamd_shingle *b)
+double rspamd_shingles_compare(const struct rspamd_shingle *a,
+ const struct rspamd_shingle *b)
{
- gint i, common = 0;
+ int i, common = 0;
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
if (a->hashes[i] == b->hashes[i]) {
@@ -408,5 +408,5 @@ gdouble rspamd_shingles_compare(const struct rspamd_shingle *a,
}
}
- return (gdouble) common / (gdouble) RSPAMD_SHINGLE_SIZE;
+ return (double) common / (double) RSPAMD_SHINGLE_SIZE;
}