@@ -25,12 +25,27 @@ typedef struct g_proxy_config_gnome3_s {
2525 // Glib module handle
2626 void * glib_module ;
2727 // Glib memory functions
28+ #if G_GNUC_CHECK_VERSION (4 , 1 ) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED )
29+ void (* g_free_sized )(gpointer mem , size_t size );
30+ #endif
2831 void (* g_free )(gpointer mem );
2932 void (* g_strfreev )(gchar * * str_array );
3033} g_proxy_config_gnome3_s ;
3134
3235g_proxy_config_gnome3_s g_proxy_config_gnome3 ;
3336
37+ #ifdef g_free
38+ # undef g_free
39+ # if G_GNUC_CHECK_VERSION (4 , 1 ) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED )
40+ # define g_free (mem ) \
41+ (__builtin_object_size((mem), 0) != ((size_t)-1)) \
42+ ? g_proxy_config_gnome3.g_free_sized(mem, __builtin_object_size((mem), 0)) \
43+ : (g_proxy_config_gnome3.g_free)(mem)
44+ # else
45+ # define gfree (mem ) (g_proxy_config_gnome3.g_free)(mem)
46+ # endif
47+ #endif
48+
3449static bool proxy_config_gnome3_is_mode (const char * mode ) {
3550 bool equal = false;
3651
@@ -41,7 +56,7 @@ static bool proxy_config_gnome3_is_mode(const char *mode) {
4156 char * system_mode = g_proxy_config_gnome3 .g_settings_get_string (settings , "mode" );
4257 if (system_mode ) {
4358 equal = strcmp (system_mode , mode ) == 0 ;
44- g_proxy_config_gnome3 . g_free (system_mode );
59+ g_free (system_mode );
4560 }
4661 g_proxy_config_gnome3 .g_object_unref (settings );
4762 return equal ;
@@ -63,7 +78,7 @@ char *proxy_config_gnome3_get_auto_config_url(void) {
6378 if (url ) {
6479 if (* url )
6580 auto_config_url = strdup (url );
66- g_proxy_config_gnome3 . g_free (url );
81+ g_free (url );
6782 }
6883 g_proxy_config_gnome3 .g_object_unref (settings );
6984 return auto_config_url ;
@@ -108,7 +123,7 @@ char *proxy_config_gnome3_get_proxy(const char *scheme) {
108123 snprintf (proxy , max_proxy , "%s:%" PRIu32 "" , host , port );
109124 }
110125
111- g_proxy_config_gnome3 . g_free (host );
126+ g_free (host );
112127 }
113128 g_proxy_config_gnome3 .g_object_unref (settings );
114129 return proxy ;
@@ -162,9 +177,15 @@ bool proxy_config_gnome3_global_init(void) {
162177 goto gnome3_init_error ;
163178
164179 // Glib functions
165- g_proxy_config_gnome3 .g_free = (void (* )(gpointer ))dlsym (g_proxy_config_gnome3 .glib_module , "g_free" );
180+ ( g_proxy_config_gnome3 .g_free ) = (void (* )(gpointer ))dlsym (g_proxy_config_gnome3 .glib_module , "g_free" );
166181 if (!g_proxy_config_gnome3 .g_free )
167182 goto gnome3_init_error ;
183+ #if G_GNUC_CHECK_VERSION (4 , 1 ) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED )
184+ g_proxy_config_gnome3 .g_free_sized =
185+ (void (* )(gpointer , size_t ))dlsym (g_proxy_config_gnome3 .glib_module , "g_free_sized" );
186+ if (!g_proxy_config_gnome3 .g_free_sized )
187+ goto gnome3_init_error ;
188+ #endif
168189 g_proxy_config_gnome3 .g_strfreev = (void (* )(gchar * * ))dlsym (g_proxy_config_gnome3 .glib_module , "g_strfreev" );
169190 if (!g_proxy_config_gnome3 .g_strfreev )
170191 goto gnome3_init_error ;
0 commit comments