projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
small optims.
[apps/madmutt.git]
/
hcache.c
diff --git
a/hcache.c
b/hcache.c
index
77f3b58
..
8560ef6
100644
(file)
--- a/
hcache.c
+++ b/
hcache.c
@@
-41,6
+41,7
@@
#endif
#include <lib-lib/mem.h>
#endif
#include <lib-lib/mem.h>
+#include <lib-lib/macros.h>
#include <lib-hash/hash.h>
#include <lib-mime/mime.h>
#include <lib-hash/hash.h>
#include <lib-mime/mime.h>
@@
-74,24
+75,16
@@
typedef union {
unsigned long uid_validity;
} validate;
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)
}
static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off)