aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-02-13 15:04:24 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-02-13 15:04:24 +0000
commitdca0a49e6d35f157e7ffdf8b0f3e61f707013e09 (patch)
tree59991c3201206adb2ea071697921d66a6b7b3b97 /src
parent2cc55730c95794b427fd9fd9c1d9ad82e37b9696 (diff)
downloadrspamd-dca0a49e6d35f157e7ffdf8b0f3e61f707013e09.tar.gz
rspamd-dca0a49e6d35f157e7ffdf8b0f3e61f707013e09.zip
[Fix] Make stat tokens allocation consistent
Diffstat (limited to 'src')
-rw-r--r--src/libstat/stat_api.h9
-rw-r--r--src/libstat/tokenizers/osb.c9
2 files changed, 9 insertions, 9 deletions
diff --git a/src/libstat/stat_api.h b/src/libstat/stat_api.h
index 1badb2001..798d0b481 100644
--- a/src/libstat/stat_api.h
+++ b/src/libstat/stat_api.h
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -53,13 +53,14 @@ typedef struct rspamd_stat_token_s {
guint flags;
} rspamd_stat_token_t;
+#define RSPAMD_TOKEN_VALUE_TYPE float
typedef struct token_node_s {
guint64 data;
guint window_idx;
guint flags;
rspamd_stat_token_t *t1;
rspamd_stat_token_t *t2;
- float values[];
+ RSPAMD_TOKEN_VALUE_TYPE values[0];
} rspamd_token_t;
struct rspamd_stat_ctx;
diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c
index d871c7a4e..e96748a93 100644
--- a/src/libstat/tokenizers/osb.c
+++ b/src/libstat/tokenizers/osb.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -302,9 +302,8 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
hashpipe[i].h = 0xfe;
hashpipe[i].t = NULL;
}
-
token_size = sizeof(rspamd_token_t) +
- sizeof(gdouble) * ctx->statfiles->len;
+ sizeof(RSPAMD_TOKEN_VALUE_TYPE) * ctx->statfiles->len;
g_assert(token_size > 0);
for (w = 0; w < words->len; w++) {