some dead code, old things, fix idna *again*
[apps/madmutt.git] / hcache.c
index 77f3b58..a757415 100644 (file)
--- a/hcache.c
+++ b/hcache.c
@@ -41,6 +41,7 @@
 #endif
 
 #include <lib-lib/mem.h>
+#include <lib-lib/macros.h>
 #include <lib-hash/hash.h>
 
 #include <lib-mime/mime.h>
@@ -74,24 +75,16 @@ typedef union {
   unsigned long uid_validity;
 } validate;
 
-static void *lazy_malloc (ssize_t siz)
-{
-  if (0 < siz && siz < 4096) {
-    siz = 4096;
-  }
+#define UPPER4K(i)  ((i & ~(4096 - 1)) + 4096)
 
-  return xmalloc(siz);
+static unsigned char *lazy_malloc(ssize_t siz)
+{
+    return p_new(unsigned char, UPPER4K(siz));
 }
 
-static void lazy_realloc(void *ptr, ssize_t siz)
+static void lazy_realloc(unsigned char **p, ssize_t siz)
 {
-  char **p = ptr;
-
-  if (p != NULL && 0 < siz && siz < 4096) {
-    return;
-  }
-
-  p_realloc(&p, siz);
+    p_realloc(p, UPPER4K(siz));
 }
 
 static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off)
@@ -215,7 +208,7 @@ static void restore_list (string_list_t ** l, const unsigned char *d, int *off)
   *l = NULL;
 }
 
-static unsigned char *dump_parameter (PARAMETER * p, unsigned char *d,
+static unsigned char *dump_parameter (parameter_t * p, unsigned char *d,
                                       int *off)
 {
   unsigned int counter = 0;
@@ -236,21 +229,19 @@ static unsigned char *dump_parameter (PARAMETER * p, unsigned char *d,
 }
 
 static void
-restore_parameter (PARAMETER ** p, const unsigned char *d, int *off)
+restore_parameter (parameter_t ** p, const unsigned char *d, int *off)
 {
   unsigned int counter;
 
   restore_int (&counter, d, off);
 
   while (counter) {
-    *p = p_new(PARAMETER, 1);
+    *p = parameter_new();
     restore_char (&(*p)->attribute, d, off);
     restore_char (&(*p)->value, d, off);
     p = &(*p)->next;
     counter--;
   }
-
-  *p = NULL;
 }
 
 static unsigned char *dump_body (BODY * c, unsigned char *d, int *off)
@@ -513,7 +504,7 @@ HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
   h->env = envelope_new();
   restore_envelope (h->env, d, &off);
 
-  h->content = mutt_new_body ();
+  h->content = body_new();
   restore_body (h->content, d, &off);
 
   restore_char (&h->maildir_flags, d, &off);