Browse Source

[Minor] Add older glib compat

tags/1.9.1
Vsevolod Stakhov 5 years ago
parent
commit
6c98a7447d
2 changed files with 26 additions and 0 deletions
  1. 23
    0
      src/libutil/util.c
  2. 3
    0
      src/libutil/util.h

+ 23
- 0
src/libutil/util.c View File

@@ -1487,6 +1487,29 @@ g_ptr_array_insert (GPtrArray *array, gint index_, gpointer data)
}
#endif

#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 32))
const gchar *
g_environ_getenv (gchar **envp, const gchar *variable)
{
gsize len;
gint i;

if (envp == NULL) {
return NULL;
}

len = strlen (variable);

for (i = 0; envp[i]; i++) {
if (strncmp (envp[i], variable, len) == 0 && envp[i][len] == '=') {
return envp[i] + len + 1;
}
}

return NULL;
}
#endif

gint
rspamd_fallocate (gint fd, off_t offset, off_t len)
{

+ 3
- 0
src/libutil/util.h View File

@@ -195,6 +195,9 @@ void g_ptr_array_insert (GPtrArray *array, gint index_, gpointer data);
GPtrArray* g_ptr_array_new_full (guint reserved_size,
GDestroyNotify element_free_func);
#endif
#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 32))
const gchar *g_environ_getenv (gchar **envp, const gchar *variable);
#endif

/*
* Convert milliseconds to timeval fields

Loading…
Cancel
Save