mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
gtk: Move from g_memdup() to g_memdup2()
The g_memdup() function is replaced by a safer version in newer versions of GLib.
This commit is contained in:
parent
a9c616284a
commit
78e3908a00
@ -28,6 +28,9 @@
|
||||
#include "gtkversion.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
|
||||
/* XXX: For g_memdup2() */
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -1610,7 +1613,7 @@ create_subparser (GObject *object,
|
||||
subparser->child = child;
|
||||
subparser->tagname = g_strdup (element_name);
|
||||
subparser->start = element_name;
|
||||
subparser->parser = g_memdup (parser, sizeof (GtkBuildableParser));
|
||||
subparser->parser = g_memdup2 (parser, sizeof (GtkBuildableParser));
|
||||
subparser->data = user_data;
|
||||
|
||||
return subparser;
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
|
||||
/* XXX: For g_memdup2() */
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -441,9 +444,9 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
|
||||
|
||||
resolved = gtk_css_keyframes_alloc ();
|
||||
resolved->n_keyframes = keyframes->n_keyframes;
|
||||
resolved->keyframe_progress = g_memdup (keyframes->keyframe_progress, keyframes->n_keyframes * sizeof (double));
|
||||
resolved->keyframe_progress = g_memdup2 (keyframes->keyframe_progress, keyframes->n_keyframes * sizeof (double));
|
||||
resolved->n_properties = keyframes->n_properties;
|
||||
resolved->property_ids = g_memdup (keyframes->property_ids, keyframes->n_properties * sizeof (guint));
|
||||
resolved->property_ids = g_memdup2 (keyframes->property_ids, keyframes->n_properties * sizeof (guint));
|
||||
resolved->values = g_new0 (GtkCssValue *, resolved->n_keyframes * resolved->n_properties);
|
||||
|
||||
for (p = 0; p < resolved->n_properties; p++)
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
#include "gtkcssnodedeclarationprivate.h"
|
||||
|
||||
/* XXX: For g_memdup2() */
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct _GtkCssNodeDeclaration {
|
||||
@ -51,7 +54,7 @@ gtk_css_node_declaration_make_writable (GtkCssNodeDeclaration **decl)
|
||||
|
||||
(*decl)->refcount--;
|
||||
|
||||
*decl = g_memdup (*decl, sizeof_this_node (*decl));
|
||||
*decl = g_memdup2 (*decl, sizeof_this_node (*decl));
|
||||
(*decl)->refcount = 1;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,9 @@
|
||||
|
||||
#include "gtkexpression.h"
|
||||
|
||||
/* XXX: For g_memdup2() */
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
||||
/**
|
||||
@ -685,7 +688,7 @@ gtk_expression_type_register_static (const char *type_name,
|
||||
info.base_finalize = NULL;
|
||||
info.class_init = gtk_expression_generic_class_init;
|
||||
info.class_finalize = NULL;
|
||||
info.class_data = g_memdup (type_info, sizeof (GtkExpressionTypeInfo));
|
||||
info.class_data = g_memdup2 (type_info, sizeof (GtkExpressionTypeInfo));
|
||||
|
||||
info.instance_size = type_info->instance_size;
|
||||
info.n_preallocs = 0;
|
||||
|
@ -2831,7 +2831,7 @@ _gtk_range_get_stop_positions (GtkRange *range,
|
||||
gtk_range_calc_marks (range);
|
||||
|
||||
if (values)
|
||||
*values = g_memdup (priv->mark_pos, priv->n_marks * sizeof (int));
|
||||
*values = g_memdup2 (priv->mark_pos, priv->n_marks * sizeof (int));
|
||||
|
||||
return priv->n_marks;
|
||||
}
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
|
||||
/* XXX: For g_memdup2() */
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
@ -106,7 +109,7 @@ append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative)
|
||||
cairo_arc (tmp, 0.0, 0.0, 1.0, angle1, angle2);
|
||||
|
||||
arc = fixup_path (cairo_copy_path (tmp));
|
||||
g_hash_table_insert (arc_path_cache, g_memdup (&key, sizeof (key)), arc);
|
||||
g_hash_table_insert (arc_path_cache, g_memdup2 (&key, sizeof (key)), arc);
|
||||
|
||||
cairo_destroy (tmp);
|
||||
cairo_surface_destroy (surface);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "gtktreednd.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtktreednd
|
||||
@ -245,7 +246,7 @@ struct _GtkTreeRowData
|
||||
static GtkTreeRowData *
|
||||
gtk_tree_row_data_copy (GtkTreeRowData *src)
|
||||
{
|
||||
return g_memdup (src, sizeof (GtkTreeRowData) + strlen (src->path) + 1 -
|
||||
return g_memdup2 (src, sizeof (GtkTreeRowData) + strlen (src->path) + 1 -
|
||||
(sizeof (GtkTreeRowData) - G_STRUCT_OFFSET (GtkTreeRowData, path)));
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,10 @@ typedef struct _GtkPrintBackendCupsClass GtkPrintBackendCupsClass;
|
||||
#define _CUPS_MAP_ATTR_INT(attr, v, a) {if (!g_ascii_strcasecmp (attr->name, (a))) v = attr->values[0].integer;}
|
||||
#define _CUPS_MAP_ATTR_STR(attr, v, a) {if (!g_ascii_strcasecmp (attr->name, (a))) v = attr->values[0].string.text;}
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 67, 3)
|
||||
# define g_memdup2(mem,size) g_memdup((mem), (size))
|
||||
#endif
|
||||
|
||||
typedef void (* GtkPrintCupsResponseCallbackFunc) (GtkPrintBackend *print_backend,
|
||||
GtkCupsResult *result,
|
||||
gpointer user_data);
|
||||
@ -6568,8 +6572,8 @@ localtime_to_utctime (const char *local_time)
|
||||
time_t rawtime;
|
||||
time (&rawtime);
|
||||
|
||||
actual_utc_time = g_memdup (gmtime (&rawtime), sizeof (struct tm));
|
||||
actual_local_time = g_memdup (localtime (&rawtime), sizeof (struct tm));
|
||||
actual_utc_time = g_memdup2 (gmtime (&rawtime), sizeof (struct tm));
|
||||
actual_local_time = g_memdup2 (localtime (&rawtime), sizeof (struct tm));
|
||||
|
||||
diff_time.tm_hour = actual_utc_time->tm_hour - actual_local_time->tm_hour;
|
||||
diff_time.tm_min = actual_utc_time->tm_min - actual_local_time->tm_min;
|
||||
|
Loading…
Reference in New Issue
Block a user