diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2021-03-25 14:09:11 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-03-29 12:42:37 +1000 |
commit | 7452b74c95c306ce53b39192c26f6cf746f3d543 (patch) | |
tree | 373a37ddf9098bece61721442d3f3807369fed5e | |
parent | d70da0842ddb086c10cb22679e80a5ab20331490 (diff) | |
download | libwacom-7452b74c95c306ce53b39192c26f6cf746f3d543.tar.gz |
Switch the stylus' paired_ids to a GArray
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | libwacom/libwacom-database.c | 7 | ||||
-rw-r--r-- | libwacom/libwacom.c | 7 | ||||
-rw-r--r-- | libwacom/libwacomint.h | 3 |
3 files changed, 7 insertions, 10 deletions
diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c index 6407e26..faa5934 100644 --- a/libwacom/libwacom-database.c +++ b/libwacom/libwacom-database.c @@ -266,24 +266,21 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, const char *path) g_free (type); string_list = g_key_file_get_string_list (keyfile, groups[i], "PairedStylusIds", NULL, NULL); + stylus->paired_ids = g_array_new (FALSE, FALSE, sizeof(int)); if (string_list) { - GArray *array; guint j; - array = g_array_new (FALSE, FALSE, sizeof(int)); for (j = 0; string_list[j]; j++) { int val; if (safe_atoi_base (string_list[j], &val, 16)) { - g_array_append_val (array, val); - stylus->num_ids++; + g_array_append_val (stylus->paired_ids, val); } else { g_warning ("Stylus %s (%s) Ignoring invalid PairedId value\n", stylus->name, groups[i]); } } g_strfreev (string_list); - stylus->paired_ids = (int *) g_array_free (array, FALSE); } stylus->has_lens = g_key_file_get_boolean(keyfile, groups[i], "HasLens", &error); diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index 1e6a3b1..39eaec6 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -1233,8 +1233,8 @@ LIBWACOM_EXPORT const int * libwacom_stylus_get_paired_ids(const WacomStylus *stylus, int *num_paired_ids) { if (num_paired_ids) - *num_paired_ids = stylus->num_ids; - return stylus->paired_ids; + *num_paired_ids = stylus->paired_ids->len; + return (const int*)stylus->paired_ids->data; } LIBWACOM_EXPORT int @@ -1368,7 +1368,8 @@ libwacom_stylus_unref(WacomStylus *stylus) g_free (stylus->name); g_free (stylus->group); - g_free (stylus->paired_ids); + if (stylus->paired_ids) + g_array_free (stylus->paired_ids, TRUE); g_free (stylus); return NULL; diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h index 07b5175..78f15ec 100644 --- a/libwacom/libwacomint.h +++ b/libwacom/libwacomint.h @@ -107,8 +107,7 @@ struct _WacomStylus { char *group; int num_buttons; gboolean has_eraser; - int num_ids; - int *paired_ids; + GArray *paired_ids; WacomEraserType eraser_type; gboolean has_lens; gboolean has_wheel; |