On Fri, Sep 03, 2021 at 02:51:21PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> That was most probably already discussed, so sorry my question:
>
> Why we can't just do
>
> #if ! GLIB_CHECK_VERSION(2, 68, 0)
> static inline gpointer g_memdup2(gconstpointer mem, gsize byte_size)
> {
> gpointer new_mem;
>
> if (mem && byte_size != 0) {
> new_mem = g_malloc(byte_size);
> memcpy(new_mem, mem, byte_size);
> } else {
> new_mem = NULL;
> }
>
> return new_mem;
> }
> #endif
>
> ?
This doesn't play with GLIB_VERSION_MAX_ALLOWED - any use of
g_memdup2 will trigger compile warnings since we're using an
API that only exists in a glib version newer than our declared
baseline.
The inline wrapper + macro is a trick that lets us backport
new features, while avoiding the compile warnings.
This is documented in the include/glib-compat.h file that Philippe
is modifying.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|