and less size_t's
[apps/madmutt.git] / hcache.c
index e089bf1..9c78a82 100644 (file)
--- a/hcache.c
+++ b/hcache.c
@@ -42,6 +42,7 @@
 
 #include <lib-lib/mem.h>
 #include <lib-hash/hash.h>
+#include <lib-lib/debug.h>
 
 #include <lib-mime/mime.h>
 
@@ -50,8 +51,6 @@
 #include "mx.h"
 #include "lib.h"
 
-#include "lib/debug.h"
-
 static struct header_cache {
 #if defined(HAVE_QDBM)
   VILLA *db;
@@ -75,7 +74,7 @@ typedef union {
   unsigned long uid_validity;
 } validate;
 
-static void *lazy_malloc (size_t siz)
+static void *lazy_malloc (ssize_t siz)
 {
   if (0 < siz && siz < 4096) {
     siz = 4096;
@@ -86,13 +85,13 @@ static void *lazy_malloc (size_t siz)
 
 static void lazy_realloc(void *ptr, ssize_t siz)
 {
-  void **p = (void **) ptr;
+  char **p = ptr;
 
   if (p != NULL && 0 < siz && siz < 4096) {
     return;
   }
 
-  p_realloc(p, siz);
+  p_realloc(&p, siz);
 }
 
 static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off)
@@ -201,7 +200,7 @@ static void restore_address (address_t ** a, const unsigned char *d, int *off)
   *a = NULL;
 }
 
-static unsigned char *dump_list (LIST * l, unsigned char *d, int *off)
+static unsigned char *dump_list (string_list_t * l, unsigned char *d, int *off)
 {
   unsigned int counter = 0;
   unsigned int start_off = *off;
@@ -219,14 +218,14 @@ static unsigned char *dump_list (LIST * l, unsigned char *d, int *off)
   return d;
 }
 
-static void restore_list (LIST ** l, const unsigned char *d, int *off)
+static void restore_list (string_list_t ** l, const unsigned char *d, int *off)
 {
   unsigned int counter;
 
   restore_int (&counter, d, off);
 
   while (counter) {
-    *l = p_new(LIST, 1);
+    *l = p_new(string_list_t, 1);
     restore_char (&(*l)->data, d, off);
     l = &(*l)->next;
     counter--;
@@ -425,7 +424,7 @@ static void restore_envelope (ENVELOPE * e, const unsigned char *d, int *off)
 }
 
 static
-unsigned int crc32 (unsigned int crc, unsigned char const *p, size_t len)
+unsigned int crc32 (unsigned int crc, unsigned char const *p, ssize_t len)
 {
   int i;
 
@@ -636,7 +635,7 @@ mutt_hcache_close(void *db)
 
 void *
 mutt_hcache_fetch(void *db, const char *filename,
-                 size_t(*keylen) (const char *fn))
+                 ssize_t(*keylen) (const char *fn))
 {
   struct header_cache *h = db;
   char path[_POSIX_PATH_MAX];
@@ -665,7 +664,7 @@ mutt_hcache_fetch(void *db, const char *filename,
 int
 mutt_hcache_store(void *db, const char *filename, HEADER * header,
                  unsigned long uid_validity,
-                 size_t(*keylen) (const char *fn))
+                 ssize_t(*keylen) (const char *fn))
 {
   struct header_cache *h = db;
   char path[_POSIX_PATH_MAX];
@@ -692,7 +691,7 @@ mutt_hcache_store(void *db, const char *filename, HEADER * header,
 
 int
 mutt_hcache_delete(void *db, const char *filename,
-                  size_t(*keylen) (const char *fn))
+                  ssize_t(*keylen) (const char *fn))
 {
   struct header_cache *h = db;
   char path[_POSIX_PATH_MAX];
@@ -760,7 +759,7 @@ void mutt_hcache_close (void *db)
 }
 
 void *mutt_hcache_fetch (void *db, const char *filename,
-                         size_t (*keylen) (const char *fn))
+                         ssize_t (*keylen) (const char *fn))
 {
   struct header_cache *h = db;
   datum key;
@@ -789,7 +788,7 @@ void *mutt_hcache_fetch (void *db, const char *filename,
 
 int
 mutt_hcache_store (void *db, const char *filename, HEADER * header,
-                   unsigned long uid_validity, size_t (*keylen) (const char *fn))
+                   unsigned long uid_validity, ssize_t (*keylen) (const char *fn))
 {
   struct header_cache *h = db;
   datum key;
@@ -818,7 +817,7 @@ mutt_hcache_store (void *db, const char *filename, HEADER * header,
 
 int
 mutt_hcache_delete (void *db, const char *filename,
-                    size_t (*keylen) (const char *fn))
+                    ssize_t (*keylen) (const char *fn))
 {
   datum key;
   struct header_cache *h = db;
@@ -838,7 +837,7 @@ mutt_hcache_delete (void *db, const char *filename,
 }
 #elif defined(HAVE_DB4)
 
-static void mutt_hcache_dbt_init (DBT * dbt, void *data, size_t len)
+static void mutt_hcache_dbt_init (DBT * dbt, void *data, ssize_t len)
 {
   dbt->data = data;
   dbt->size = dbt->ulen = len;
@@ -940,7 +939,7 @@ void mutt_hcache_close (void *db)
 }
 
 void *mutt_hcache_fetch (void *db, const char *filename,
-                         size_t (*keylen) (const char *fn))
+                         ssize_t (*keylen) (const char *fn))
 {
   DBT key;
   DBT data;
@@ -968,7 +967,7 @@ void *mutt_hcache_fetch (void *db, const char *filename,
 
 int
 mutt_hcache_store (void *db, const char *filename, HEADER * header,
-                   unsigned long uid_validity, size_t (*keylen) (const char *fn))
+                   unsigned long uid_validity, ssize_t (*keylen) (const char *fn))
 {
   DBT key;
   DBT data;
@@ -998,7 +997,7 @@ mutt_hcache_store (void *db, const char *filename, HEADER * header,
 
 int
 mutt_hcache_delete (void *db, const char *filename,
-                    size_t (*keylen) (const char *fn))
+                    ssize_t (*keylen) (const char *fn))
 {
   DBT key;
   struct header_cache *h = db;