* use the slice allocator
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 2 Feb 2007 12:57:46 +0000 (12:57 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 2 Feb 2007 12:57:46 +0000 (12:57 +0000)
pmo-trunk-r782

src/modest-account-mgr-helpers.c
src/modest-pair.c
src/modest-pair.h
src/modest-text-utils.c

index 07e62d3..57ba232 100644 (file)
@@ -60,8 +60,8 @@ modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar*
        
        g_return_val_if_fail (modest_account_mgr_account_exists (self, name,
                                                                 TRUE, NULL), NULL);    
-       data = g_new0 (ModestServerAccountData, 1);
-
+       data = g_slice_new0 (ModestServerAccountData);
+       
        data->account_name = g_strdup (name);
        data->hostname     = modest_account_mgr_get_string (self, name,
                                                            MODEST_ACCOUNT_HOSTNAME,
@@ -117,7 +117,7 @@ modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
                g_slist_free (data->options);
        }
 
-       g_free (data);
+       g_slice_free (ModestServerAccountData, data);
 }
 
 ModestAccountData*
@@ -130,7 +130,7 @@ modest_account_mgr_get_account_data     (ModestAccountMgr *self, const gchar* na
        g_return_val_if_fail (name, NULL);
        g_return_val_if_fail (modest_account_mgr_account_exists (self, name,
                                                                 FALSE, NULL), NULL);   
-       data = g_new0 (ModestAccountData, 1);
+       data = g_slice_new0 (ModestAccountData);
 
        data->account_name = g_strdup (name);
 
@@ -187,7 +187,7 @@ modest_account_mgr_free_account_data (ModestAccountMgr *self, ModestAccountData
        modest_account_mgr_free_server_account_data (self, data->store_account);
        modest_account_mgr_free_server_account_data (self, data->transport_account);
        
-       g_free (data);
+       g_slice_free (ModestAccountData, data);
 }
 
 
index 0f67b84..25f14ca 100644 (file)
@@ -34,11 +34,11 @@ modest_pair_new     (gpointer first, gpointer second, gboolean own)
 {
        ModestPair *pair;
 
-       pair = g_new (ModestPair, 1);
+       pair = g_slice_new (ModestPair);
 
-       pair->first = first;
+       pair->first  = first;
        pair->second = second;
-       pair->own = own;
+       pair->own    = own;
        
        return pair;
 }
@@ -54,12 +54,13 @@ modest_pair_free (ModestPair *pair)
                g_free (pair->first);
                g_free (pair->second);
        }
-       g_free (pair);
+       
+       g_slice_free (ModestPair, pair);
 }
 
 
 
-ModestPairList*
+void
 modest_pair_list_free (ModestPairList *pairs)
 {
        ModestPairList *cursor = pairs;
@@ -68,5 +69,4 @@ modest_pair_list_free (ModestPairList *pairs)
                cursor = cursor->next;
        }
        g_slist_free (pairs);
-       return NULL;
 }
index e1ebbfd..412bf4a 100644 (file)
@@ -67,16 +67,14 @@ ModestPair* modest_pair_new   (gpointer first, gpointer second, gboolean own);
 void        modest_pair_free       (ModestPair *self);
 
 
-
 /**
  * modest_pair_list_free:
  * @pairs: a valid ModestPairList
  *
  * convenience function to destroy all pairs in a list 
  *
- * Returns: NULL
  */
-ModestPairList      *modest_pair_list_free (ModestPairList *pairs);
+void  modest_pair_list_free (ModestPairList *pairs);
 
 G_END_DECLS
 
index e1f82cc..0bcc66c 100644 (file)
@@ -600,9 +600,11 @@ get_url_matches (GString *txt)
 
        /* initalize the regexps */
        for (i = 0; i != pattern_num; ++i) {
-               patterns[i].preg = g_new0 (regex_t,1);
-               g_assert(regcomp (patterns[i].preg, patterns[i].regex,
-                                 REG_ICASE|REG_EXTENDED|REG_NEWLINE) == 0);
+               patterns[i].preg = g_slice_new0 (regex_t);
+
+               /* this should not happen */
+               g_return_val_if_fail (regcomp (patterns[i].preg, patterns[i].regex,
+                                              REG_ICASE|REG_EXTENDED|REG_NEWLINE) == 0, NULL);
        }
         /* find all the matches */
        for (i = 0; i != pattern_num; ++i) {
@@ -610,7 +612,7 @@ get_url_matches (GString *txt)
                while (1) {
                        int test_offset;
                        if ((rv = regexec (patterns[i].preg, txt->str + offset, 1, &rm, 0)) != 0) {
-                               g_assert (rv == REG_NOMATCH); /* this should not happen */
+                               g_return_val_if_fail (rv == REG_NOMATCH, NULL); /* this should not happen */
                                break; /* try next regexp */ 
                        }
                        if (rm.rm_so == -1)
@@ -624,7 +626,7 @@ get_url_matches (GString *txt)
                        
                        /* make a list of our matches (<offset, len, prefix> tupels)*/
                        if (test_offset != -1) {
-                               url_match_t *match = g_new (url_match_t,1);
+                               url_match_t *match = g_slice_new (url_match_t);
                                match->offset = offset + rm.rm_so;
                                match->len    = rm.rm_eo - rm.rm_so;
                                match->prefix = patterns[i].prefix;
@@ -636,7 +638,7 @@ get_url_matches (GString *txt)
 
        for (i = 0; i != pattern_num; ++i) {
                regfree (patterns[i].preg);
-               g_free  (patterns[i].preg);
+               g_slice_free  (regex_t, patterns[i].preg);
        } /* don't free patterns itself -- it's static */
        
        /* now sort the list, so the matches are in reverse order of occurence.
@@ -675,7 +677,7 @@ hyperlinkify_plain_text (GString *txt)
                g_free (url);
                g_free (repl);
 
-               g_free (cursor->data);  
+               g_slice_free (url_match_t, match);      
        }
        
        g_slist_free (match_list);