diff options
author | Frediano Ziglio <freddy77@gmail.com> | 2021-08-12 12:31:58 +0100 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2021-08-12 14:58:49 +0200 |
commit | 21649747849c464cc8e67b832d1d5582e66eaee8 (patch) | |
tree | d3649f29fa4ee5255d19275b8e6b29314bbca63a /src | |
parent | 9c40d3b5a65e5d2f5244085061e3c96a6142ecea (diff) |
Fix issue using g_memdup2
Due to the way Autoconf works you cannot reuse PKG_CHECK_MODULES
for the same library so the compilation failed on some systems.
Check using just code and defines instead of using configuration
software.
Also avoids macros to avoid side effects.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/common.c | 14 | ||||
-rw-r--r-- | src/common.h | 7 | ||||
-rw-r--r-- | src/vcard_emul_nss.c | 1 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/common.c b/src/common.c index 5ec3cfa..044413e 100644 --- a/src/common.c +++ b/src/common.c @@ -79,4 +79,18 @@ hex_dump(const unsigned char *buf, size_t buflen) *--p = '\x00'; return start; } + +#if !GLIB_CHECK_VERSION(2,68,0) +void* g_memdup2(const void *ptr, size_t size) +{ + void *dst = NULL; + + if (ptr && size != 0) { + dst = g_malloc(size); + memcpy(dst, ptr, size); + } + return dst; +} +#endif + /* vim: set ts=4 sw=4 tw=0 noet expandtab: */ diff --git a/src/common.h b/src/common.h index d513edc..eb72324 100644 --- a/src/common.h +++ b/src/common.h @@ -25,16 +25,15 @@ #define _COMMON_H #include <stddef.h> - -#include "config.h" +#include <glib.h> unsigned char *ushort2lebytes(unsigned char *buf, unsigned short x); unsigned short lebytes2ushort(const unsigned char *buf); char *hex_dump(const unsigned char *buf, size_t buflen); -#ifndef HAVE_G_MEMDUP2 -#define g_memdup2(ptr,sz) ((G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(), NULL)) +#if !GLIB_CHECK_VERSION(2,68,0) +void* g_memdup2(const void *ptr, size_t size); #endif #endif diff --git a/src/vcard_emul_nss.c b/src/vcard_emul_nss.c index 289a60a..b63105d 100644 --- a/src/vcard_emul_nss.c +++ b/src/vcard_emul_nss.c @@ -9,6 +9,7 @@ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING file in the top-level directory. */ +#include "config.h" #include <glib.h> |