From 6af48d75a46c26cc00a87369a81321f0b0972870 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Mon, 2 Mar 2015 17:33:51 +0100 Subject: [PATCH] monitor-manager-kms: Don't store a list of encoders It's not needed outside of read_current() and current_encoder is totally unused. https://bugzilla.gnome.org/show_bug.cgi?id=745476 --- .../native/meta-monitor-manager-kms.c | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c index 29c8e2479..eeb5877b1 100644 --- a/src/backends/native/meta-monitor-manager-kms.c +++ b/src/backends/native/meta-monitor-manager-kms.c @@ -66,11 +66,6 @@ struct _MetaMonitorManagerKms drmModeConnector **connectors; unsigned int n_connectors; - drmModeEncoder **encoders; - unsigned int n_encoders; - - drmModeEncoder *current_encoder; - GUdevClient *udev; GSettings *desktop_settings; @@ -88,12 +83,9 @@ free_resources (MetaMonitorManagerKms *manager_kms) { unsigned i; - for (i = 0; i < manager_kms->n_encoders; i++) - drmModeFreeEncoder (manager_kms->encoders[i]); for (i = 0; i < manager_kms->n_connectors; i++) drmModeFreeConnector (manager_kms->connectors[i]); - g_free (manager_kms->encoders); g_free (manager_kms->connectors); } @@ -338,6 +330,7 @@ meta_monitor_manager_kms_read_current (MetaMonitorManager *manager) { MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (manager); drmModeRes *resources; + drmModeEncoder **encoders; GHashTable *modes; GHashTableIter iter; drmModeModeInfo *mode; @@ -381,13 +374,9 @@ meta_monitor_manager_kms_read_current (MetaMonitorManager *manager) } } - manager_kms->n_encoders = resources->count_encoders; - manager_kms->encoders = g_new (drmModeEncoder *, manager_kms->n_encoders); - for (i = 0; i < manager_kms->n_encoders; i++) - { - manager_kms->encoders[i] = drmModeGetEncoder (manager_kms->fd, - resources->encoders[i]); - } + encoders = g_new (drmModeEncoder *, resources->count_encoders); + for (i = 0; i < (unsigned)resources->count_encoders; i++) + encoders[i] = drmModeGetEncoder (manager_kms->fd, resources->encoders[i]); manager->n_modes = g_hash_table_size (modes); manager->modes = g_new0 (MetaMonitorMode, manager->n_modes); @@ -625,9 +614,9 @@ meta_monitor_manager_kms_read_current (MetaMonitorManager *manager) for (j = 0; j < output_kms->n_encoders; j++) { - for (k = 0; k < manager_kms->n_encoders; k++) + for (k = 0; k < (unsigned)resources->count_encoders; k++) { - if (output_kms->encoders[j]->encoder_id == manager_kms->encoders[k]->encoder_id) + if (output_kms->encoders[j]->encoder_id == encoders[k]->encoder_id) { output_kms->encoder_mask |= (1 << k); break; @@ -674,6 +663,10 @@ meta_monitor_manager_kms_read_current (MetaMonitorManager *manager) } } + for (i = 0; i < (unsigned)resources->count_encoders; i++) + drmModeFreeEncoder (encoders[i]); + g_free (encoders); + drmModeFreeResources (resources); }