vpn: reduce memory usage a bit

No need to copy the list when (a) we never care if it gets modified
in-place (since the loops break when the connection is found) and
(b) we never modify it in place anyway.  Reduces the possibility of
leaking the list due to programming errors too.
This commit is contained in:
Dan Williams 2012-09-14 15:33:42 -05:00
parent 1fcb577e19
commit 9065f247c3
3 changed files with 5 additions and 7 deletions

View file

@ -82,7 +82,7 @@ find_active_vpn_connection_by_connection (NMVPNManager *self, NMConnection *conn
NMVPNManagerPrivate *priv = NM_VPN_MANAGER_GET_PRIVATE (self);
GHashTableIter iter;
gpointer data;
GSList *active, *aiter;
const GSList *active, *aiter;
NMVPNConnection *found = NULL;
g_return_val_if_fail (connection, NULL);
@ -99,7 +99,6 @@ find_active_vpn_connection_by_connection (NMVPNManager *self, NMConnection *conn
break;
}
}
g_slist_free (active);
}
return found;
}
@ -174,7 +173,7 @@ nm_vpn_manager_deactivate_connection (NMVPNManager *self,
NMVPNManagerPrivate *priv;
GHashTableIter iter;
gpointer data;
GSList *active, *aiter;
const GSList *active, *aiter;
gboolean success = FALSE;
g_return_val_if_fail (self, FALSE);
@ -194,7 +193,6 @@ nm_vpn_manager_deactivate_connection (NMVPNManager *self,
break;
}
}
g_slist_free (active);
}
return success;

View file

@ -369,12 +369,12 @@ nm_vpn_service_activate (NMVPNService *service,
return vpn;
}
GSList *
const GSList *
nm_vpn_service_get_active_connections (NMVPNService *service)
{
g_return_val_if_fail (NM_IS_VPN_SERVICE (service), NULL);
return g_slist_copy (NM_VPN_SERVICE_GET_PRIVATE (service)->connections);
return NM_VPN_SERVICE_GET_PRIVATE (service)->connections;
}
static void

View file

@ -62,7 +62,7 @@ NMVPNConnection * nm_vpn_service_activate (NMVPNService *service,
gulong user_uid,
GError **error);
GSList * nm_vpn_service_get_active_connections (NMVPNService *service);
const GSList *nm_vpn_service_get_active_connections (NMVPNService *service);
void nm_vpn_service_connections_stop (NMVPNService *service,
gboolean fail,