aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-24 13:11:53 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-24 13:11:53 +0100
commit215a57a76656098ba81f44d7e7033f4de0badf78 (patch)
tree5d280c6be5bde41dbb60a812094f8523f6658ddb
parent7a589308b47e6eb84bd94afd5382d5d1e86bbcbe (diff)
downloadrspamd-215a57a76656098ba81f44d7e7033f4de0badf78.tar.gz
rspamd-215a57a76656098ba81f44d7e7033f4de0badf78.zip
[Minor] Fix build with glib < 2.40
-rw-r--r--src/libserver/spf.c12
-rw-r--r--src/libutil/util.c23
-rw-r--r--src/libutil/util.h3
3 files changed, 32 insertions, 6 deletions
diff --git a/src/libserver/spf.c b/src/libserver/spf.c
index dd7843eae..2459ee7cc 100644
--- a/src/libserver/spf.c
+++ b/src/libserver/spf.c
@@ -1802,20 +1802,20 @@ spf_dns_callback (struct rdns_reply *reply, gpointer arg)
&& rec->dns_requests == 0) {
resolved = rspamd_spf_new_addr_list (rec, rec->sender_domain);
struct spf_addr *addr;
- addr = g_slice_alloc0 (sizeof (*addr));
+ addr = g_slice_alloc0 (sizeof(*addr));
addr->flags = 0;
addr->flags |= RSPAMD_SPF_FLAG_NA;
- g_ptr_array_insert(resolved->elts, 0, addr);
+ g_ptr_array_insert (resolved->elts, 0, addr);
}
-
+
if (!spf_process_txt_record (rec, resolved, reply)) {
if (rec->dns_requests == 0) {
- resolved = g_ptr_array_index (rec->resolved, 0);
+ resolved = g_ptr_array_index(rec->resolved, 0);
struct spf_addr *addr;
- addr = g_slice_alloc0 (sizeof (*addr));
+ addr = g_slice_alloc0 (sizeof(*addr));
addr->flags = 0;
addr->flags |= RSPAMD_SPF_FLAG_NA;
- g_ptr_array_insert(resolved->elts, 0, addr);
+ g_ptr_array_insert (resolved->elts, 0, addr);
}
}
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 7e7614005..9ca5bbce8 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1424,6 +1424,29 @@ g_queue_free_full (GQueue *queue, GDestroyNotify free_func)
}
#endif
+#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 40))
+void
+g_ptr_array_insert (GPtrArray *array, gint index_, gpointer data)
+{
+ g_return_if_fail (array);
+ g_return_if_fail (index_ >= -1);
+ g_return_if_fail (index_ <= (gint )array->len);
+
+ g_ptr_array_set_size (array, array->len + 1);
+
+ if (index_ < 0) {
+ index_ = array->len;
+ }
+
+ if (index_ < array->len) {
+ memmove (&(array->pdata[index_ + 1]), &(array->pdata[index_]),
+ (array->len - index_) * sizeof(gpointer));
+ }
+
+ array->pdata[index_] = data;
+}
+#endif
+
gint
rspamd_fallocate (gint fd, off_t offset, off_t len)
{
diff --git a/src/libutil/util.h b/src/libutil/util.h
index 564d00b12..946d9f09a 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -186,6 +186,9 @@ void g_queue_clear (GQueue *queue);
#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 32))
void g_queue_free_full (GQueue *queue, GDestroyNotify free_func);
#endif
+#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 40))
+void g_ptr_array_insert (GPtrArray *array, gint index_, gpointer data)
+#endif
/*
* Convert milliseconds to timeval fields