libpurple/glibcompat.h

Mon, 18 Oct 2021 01:36:58 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 18 Oct 2021 01:36:58 -0500
changeset 41105
02c3569bc32b
parent 40868
32a19e77cfa3
child 41175
372df64f6b1a
permissions
-rw-r--r--

Add gi-docgen as a subproject so we can convert the documentation to it

Testing Done:
Just compiled and verified that our `.wrap` file didn't get overwritten by a `wrap-file` from gplugin.

Reviewed at https://reviews.imfreedom.org/r/1055/

33368
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
1 /* pidgin
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
2 *
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
3 * Pidgin is the legal property of its developers, whose names are too numerous
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
5 * source distribution.
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
6 *
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
10 * (at your option) any later version.
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
11 *
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
16 *
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
20 */
35487
494f09f7f331 Move section blocks inside inclusion guards -- otherwise g-ir-scanner yells
Ankit Vani <a@nevitus.org>
parents: 35460
diff changeset
21
39659
e4dfb99b0cef Fix libpurple header guards using reserved names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39532
diff changeset
22 #ifndef PURPLE_GLIBCOMPAT_H
e4dfb99b0cef Fix libpurple header guards using reserved names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39532
diff changeset
23 #define PURPLE_GLIBCOMPAT_H
35460
96946e21fce5 Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents: 35440
diff changeset
24 /*
35440
467bb21b82a1 Add section blocks for debug.h to prpl.h
Ankit Vani <a@nevitus.org>
parents: 35306
diff changeset
25 * SECTION:glibcompat
467bb21b82a1 Add section blocks for debug.h to prpl.h
Ankit Vani <a@nevitus.org>
parents: 35306
diff changeset
26 * @section_id: libpurple-glibcompat
467bb21b82a1 Add section blocks for debug.h to prpl.h
Ankit Vani <a@nevitus.org>
parents: 35306
diff changeset
27 * @short_description: <filename>glibcompat.h</filename>
467bb21b82a1 Add section blocks for debug.h to prpl.h
Ankit Vani <a@nevitus.org>
parents: 35306
diff changeset
28 * @title: GLib version-dependent definitions
467bb21b82a1 Add section blocks for debug.h to prpl.h
Ankit Vani <a@nevitus.org>
parents: 35306
diff changeset
29 *
467bb21b82a1 Add section blocks for debug.h to prpl.h
Ankit Vani <a@nevitus.org>
parents: 35306
diff changeset
30 * This file is internal to libpurple. Do not use!
33368
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
31 * Also, any public API should not depend on this file.
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
32 */
6aa16fdab83f Fix compilation of older distros. Fixes #15310
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff changeset
33
35306
abc36dad1363 Include glib.h before messing with any defines
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35299
diff changeset
34 #include <glib.h>
abc36dad1363 Include glib.h before messing with any defines
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35299
diff changeset
35
35872
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
36 /* glib's definition of g_stat+GStatBuf seems to be broken on mingw64-w32 (and
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
37 * possibly other 32-bit windows), so instead of relying on it,
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
38 * we'll define our own.
35867
b6f09494adda cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35804
diff changeset
39 */
b6f09494adda cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35804
diff changeset
40 #if defined(_WIN32) && !defined(_MSC_VER) && !defined(_WIN64)
b6f09494adda cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35804
diff changeset
41 # include <glib/gstdio.h>
35872
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
42 typedef struct _stat GStatBufW32;
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
43 static inline int
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
44 purple_g_stat(const gchar *filename, GStatBufW32 *buf)
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
45 {
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
46 return g_stat(filename, (GStatBuf*)buf);
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
47 }
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
48 # define GStatBuf GStatBufW32
4cd48601e1d1 cross-win32: better fix for g_stat bug
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35867
diff changeset
49 # define g_stat purple_g_stat
35867
b6f09494adda cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35804
diff changeset
50 #endif
b6f09494adda cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35804
diff changeset
51
40818
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
52 #if !GLIB_CHECK_VERSION(2, 58, 0)
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
53 #define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
54
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
55 static inline GTimeZone *
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
56 g_time_zone_new_offset(gint32 seconds) {
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
57 GTimeZone *tz = NULL;
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
58 gchar *identifier = NULL;
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
59
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
60 /* Seemingly, we should be using @seconds directly to set the
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
61 * #TransitionInfo.gmt_offset to avoid all this string building and
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
62 * parsing. However, we always need to set the #GTimeZone.name to a
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
63 * constructed string anyway, so we might as well reuse its code.
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
64 */
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
65 identifier = g_strdup_printf("%c%02u:%02u:%02u",
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
66 (seconds >= 0) ? '+' : '-',
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
67 (ABS (seconds) / 60) / 60,
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
68 (ABS (seconds) / 60) % 60,
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
69 ABS (seconds) % 60);
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
70 tz = g_time_zone_new(identifier);
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
71 g_free(identifier);
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
72
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
73 g_assert(g_time_zone_get_offset(tz, 0) == seconds);
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
74
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
75 return tz;
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
76 }
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
77
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
78 #endif /* !GLIB_CHECK_VERSION(2, 58, 0) */
3891ef6e3b56 Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
79
40470
543fa511ab7c Add a compat version of g_date_time_format_iso8601 and install glibcompat.h
Gary Kramlich <grim@reaperworld.com>
parents: 40193
diff changeset
80 #if !GLIB_CHECK_VERSION(2, 62, 0)
40868
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
81 static inline gchar *
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
82 g_date_time_format_iso8601(GDateTime *datetime) {
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
83 GString *outstr = NULL;
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
84 gchar *main_date = NULL;
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
85 gint64 offset;
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
86
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
87 /* Main date and time. */
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
88 main_date = g_date_time_format(datetime, "%Y-%m-%dT%H:%M:%S");
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
89 outstr = g_string_new(main_date);
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
90 g_free(main_date);
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
91
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
92 /* Timezone. Format it as `%:::z` unless the offset is zero, in which case
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
93 * we can simply use `Z`. */
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
94 offset = g_date_time_get_utc_offset(datetime);
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
95
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
96 if (offset == 0) {
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
97 g_string_append_c(outstr, 'Z');
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
98 } else {
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
99 gchar *time_zone = g_date_time_format(datetime, "%:::z");
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
100 g_string_append(outstr, time_zone);
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
101 g_free(time_zone);
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
102 }
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
103
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
104 return g_string_free(outstr, FALSE);
32a19e77cfa3 Move purple_compat_date_time_format_iso8601 to just be a static inline with its normal glib name
Gary Kramlich <grim@reaperworld.com>
parents: 40818
diff changeset
105 }
40470
543fa511ab7c Add a compat version of g_date_time_format_iso8601 and install glibcompat.h
Gary Kramlich <grim@reaperworld.com>
parents: 40193
diff changeset
106 #endif /* GLIB_CHECK_VERSION(2, 62, 0) */
543fa511ab7c Add a compat version of g_date_time_format_iso8601 and install glibcompat.h
Gary Kramlich <grim@reaperworld.com>
parents: 40193
diff changeset
107
40756
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
108 /* Backport the static inline version of g_memdup2 if we don't have g_memdup2.
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
109 * see https://mail.gnome.org/archives/desktop-devel-list/2021-February/msg00000.html
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
110 * for more information.
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
111 */
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
112 #if !GLIB_CHECK_VERSION(2, 67, 3)
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
113 static inline gpointer
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
114 g_memdup2(gconstpointer mem, gsize byte_size) {
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
115 gpointer new_mem = NULL;
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
116
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
117 if(mem && byte_size != 0) {
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
118 new_mem = g_malloc (byte_size);
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
119 memcpy (new_mem, mem, byte_size);
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
120 }
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
121
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
122 return new_mem;
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
123 }
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
124 #endif /* !GLIB_CHECK_VERSION(2, 67, 3) */
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40562
diff changeset
125
39659
e4dfb99b0cef Fix libpurple header guards using reserved names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39532
diff changeset
126 #endif /* PURPLE_GLIBCOMPAT_H */

mercurial