[gnome-online-accounts] smtp-auth, utils: Avoid needless string copies



commit ebb1d81e1e8c29a4a9888cdb2a7752a58d2b954f
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 16 17:11:57 2016 +0100

    smtp-auth, utils: Avoid needless string copies
    
    Since we already have our own reference on the GObject, we don't need
    to duplicate the string properties.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762155

 src/goabackend/goasmtpauth.c |    6 ++----
 src/goabackend/goautils.c    |   10 +++-------
 2 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/src/goabackend/goasmtpauth.c b/src/goabackend/goasmtpauth.c
index 0161baf..91d15cd 100644
--- a/src/goabackend/goasmtpauth.c
+++ b/src/goabackend/goasmtpauth.c
@@ -220,12 +220,11 @@ smtp_auth_get_domain (GoaSmtpAuth   *self,
                       GError       **error)
 {
   GoaMail *mail;
+  const gchar *email_address;
   gchar *domain;
-  gchar *email_address;
 
   mail = NULL;
   domain = NULL;
-  email_address = NULL;
 
   if (self->domain != NULL)
     {
@@ -243,7 +242,7 @@ smtp_auth_get_domain (GoaSmtpAuth   *self,
           goto out;
         }
 
-      email_address = goa_mail_dup_email_address (mail);
+      email_address = goa_mail_get_email_address (mail);
       if (!goa_utils_parse_email_address (email_address, NULL, &domain))
         {
           g_set_error (error,
@@ -264,7 +263,6 @@ smtp_auth_get_domain (GoaSmtpAuth   *self,
 
  out:
   g_clear_object (&mail);
-  g_free (email_address);
   return domain;
 }
 
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 498b8c5..7a7a791 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -646,7 +646,7 @@ goa_utils_get_credentials (GoaProvider    *provider,
   GVariant *credentials = NULL;
   GoaAccount *account = NULL;
   gboolean ret = FALSE;
-  gchar *username = NULL;
+  const gchar *username;
   gchar *password = NULL;
 
   credentials = goa_utils_lookup_credentials_sync (provider,
@@ -657,7 +657,7 @@ goa_utils_get_credentials (GoaProvider    *provider,
     goto out;
 
   account = goa_object_get_account (object);
-  username = goa_account_dup_identity (account);
+  username = goa_account_get_identity (account);
 
   if (!g_variant_lookup (credentials, id, "s", &password))
     {
@@ -668,10 +668,7 @@ goa_utils_get_credentials (GoaProvider    *provider,
     }
 
   if (out_username)
-    {
-      *out_username = username;
-      username = NULL;
-    }
+    *out_username = g_strdup (username);
 
   if (out_password)
     {
@@ -684,7 +681,6 @@ goa_utils_get_credentials (GoaProvider    *provider,
 out:
   g_clear_object (&account);
   g_clear_pointer (&credentials, (GDestroyNotify) g_variant_unref);
-  g_free (username);
   g_free (password);
   return ret;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]