From d2b509fb231d13175dc1af47a36836540a0eea46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Mon, 11 Jun 2018 12:29:15 +0000 Subject: [PATCH] Fix some alignment issues * Use GRAPHENE_ALIGN16 to ensure that GtkSnapshotState size is a multiple of 16 * Use G_STATIC_ASSERT instead of g_return_val_if_fail to make the wrong size (if it turns out to be wrong) be a compile-time erorr instead of a runtime one --- gtk/gtksnapshot.c | 2 -- gtk/gtksnapshotprivate.h | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 9d70446791..c8025f7e46 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -67,8 +67,6 @@ gtk_snapshot_state_array_new (void) { GtkRealSnapshotStateArray *array; - g_return_val_if_fail (sizeof (GtkSnapshotState) % 16 == 0, NULL); - array = g_slice_new (GtkRealSnapshotStateArray); array->data = NULL; diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 5ecda2d501..19341a0c32 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -40,6 +40,7 @@ typedef GskRenderNode * (* GtkSnapshotCollectFunc) (GtkSnapshot *snapshot, GskRenderNode **nodes, guint n_nodes); +GRAPHENE_ALIGN16 struct _GtkSnapshotState { guint start_node_index; guint n_nodes; @@ -91,6 +92,8 @@ struct _GtkSnapshotState { } data; }; +G_STATIC_ASSERT (sizeof (GtkSnapshotState) % 16 == 0); + /* This is a nasty little hack. We typedef GtkSnapshot to the fake object GdkSnapshot * so that we don't need to typecast between them. * After all, the GdkSnapshot only exist so poor language bindings don't trip. Hardcore