From 6a4d5fab95e95f82406d3c323daf931e34e7031b Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 25 Mar 2022 12:09:59 +0100 Subject: [PATCH] mount-matrix: Split off getting the identity mount matrix --- src/accel-mount-matrix.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/accel-mount-matrix.c b/src/accel-mount-matrix.c index b5570a5..79eaade 100644 --- a/src/accel-mount-matrix.c +++ b/src/accel-mount-matrix.c @@ -24,6 +24,16 @@ static AccelVec3 id_matrix[3] = { static char axis_names[] = "xyz"; +AccelVec3 * +get_id_matrix (void) +{ +#if GLIB_CHECK_VERSION(2, 68, 0) + return g_memdup2 (id_matrix, sizeof(id_matrix)); +#else + return g_memdup (id_matrix, sizeof(id_matrix)); +#endif +} + AccelVec3 * setup_mount_matrix (GUdevDevice *device) { @@ -115,14 +125,9 @@ parse_mount_matrix (const char *mtx, g_return_val_if_fail (vecs != NULL, FALSE); - /* Empty string means we use the identity matrix */ if (mtx == NULL || *mtx == '\0') { -#if GLIB_CHECK_VERSION(2, 68, 0) - *vecs = g_memdup2 (id_matrix, sizeof(id_matrix)); -#else - *vecs = g_memdup (id_matrix, sizeof(id_matrix)); -#endif + *vecs = get_id_matrix (); return TRUE; }