drop mem_alloc and mem_free, use my own hand crafted optmized macros that
[apps/madmutt.git] / nntp / newsrc.c
index 898b148..3f707ab 100644 (file)
@@ -13,6 +13,8 @@
 #include <config.h>
 #endif
 
+#include <lib-lib/mem.h>
+
 #include "mutt.h"
 #include "mutt_curses.h"
 #include "sort.h"
@@ -87,7 +89,7 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
     nntp_add_to_list (news, data);
   }
   else
-    mem_free (&data->entries);
+    p_delete(&data->entries);
 
   data->rc = 1;
   data->entries = mem_calloc (x * 2, sizeof (NEWSRC_ENTRY));
@@ -149,10 +151,10 @@ static int slurp_newsrc (NNTP_SERVER * news)
     return -1;
   }
 
-  buf = mem_malloc (sb.st_size + 1);
+  buf = p_new(char, sb.st_size + 1);
   while (fgets (buf, sb.st_size + 1, fp))
     nntp_parse_newsrc_line (news, buf);
-  mem_free (&buf);
+  p_delete(&buf);
 
   mx_unlock_file (news->newsrc, fileno (fp), 0);
   fclose (fp);
@@ -200,7 +202,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news)
 
   set_option (OPTNEWSCACHE);
 
-  mem_free (&news->cache);
+  p_delete(&news->cache);
   snprintf (buf, sizeof (buf), "%s/.index", dir);
   if (!(index = safe_fopen (buf, "a+")))
     return 0;
@@ -305,7 +307,7 @@ int nntp_parse_url (const char *server, ACCOUNT * acct,
     ret = mutt_account_fromurl (acct, &url);
   }
 
-  mem_free (&c);
+  p_delete(&c);
   return ret;
 }
 
@@ -316,7 +318,7 @@ void nntp_expand_path (char *line, size_t len, ACCOUNT * acct)
   url.path = str_dup (line);
   mutt_account_tourl (acct, &url);
   url_ciss_tostring (&url, line, len, 0);
-  mem_free (&url.path);
+  p_delete(&url.path);
 }
 
 /*
@@ -354,11 +356,11 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
   strcpy (p, server);
 
   if ((nntp_parse_url (buf, &acct, file, sizeof (file))) < 0 || *file) {
-    mem_free (&buf);
+    p_delete(&buf);
     mutt_error (_("%s is an invalid newsserver specification!"), server);
     return NULL;
   }
-  mem_free (&buf);
+  p_delete(&buf);
 
   conn = mutt_conn_find (NULL, &acct);
   if (!conn)
@@ -409,9 +411,9 @@ NNTP_SERVER *mutt_select_newsserver (char *server)
     for (list = serv->list; list; list = list->next)
       list->data = NULL;
     mutt_free_list (&serv->list);
-    mem_free (&serv->newsrc);
-    mem_free (&serv->cache);
-    mem_free (&serv);
+    p_delete(&serv->newsrc);
+    p_delete(&serv->cache);
+    p_delete(&serv);
     return NULL;
   }
   nntp_clear_cacheindex (serv);
@@ -773,7 +775,7 @@ int mutt_newsrc_update (NNTP_SERVER * news)
     news->size = st.st_size;
     news->mtime = st.st_mtime;
   }
-  mem_free (&buf);
+  p_delete(&buf);
   return r;
 }
 
@@ -980,7 +982,7 @@ void nntp_delete_cache (NNTP_DATA * data)
 
   nntp_cache_expand (buf, data->cache);
   unlink (buf);
-  mem_free (&data->cache);
+  p_delete(&data->cache);
   data->lastCached = 0;
   nntp_cache_expand (buf, ".index");
   mutt_update_list_file (buf, data->nserv->conn->account.host, data->group,