Version 2.00.27 - 24th November 2004
====================================
+ Trap large memory allocation requests.
Fix to partition table detection code.
Improve filter debug mesgs.
misc/crc.c \
misc/lvm-file.c \
misc/lvm-string.c \
+ mm/dbg_malloc.c \
mm/memlock.c \
mm/pool.c \
regex/matcher.c \
SOURCES += mirror/mirrored.c
endif
-ifeq ("@DEBUG@", "yes")
- SOURCES += mm/dbg_malloc.c
-endif
-
ifeq ("@DEVMAPPER@", "yes")
SOURCES +=\
activate/dev_manager.c \
#include <stdarg.h>
+#ifdef DEBUG_MEM
+
struct memblock {
struct memblock *prev, *next; /* All allocated blocks are linked */
size_t length; /* Size of the requested block */
if (s > 50000000) {
log_error("Huge memory allocation (size %" PRIuPTR
- ") rejected - bug?", s);
+ ") rejected - metadata corruption?", s);
return 0;
}
return r;
}
-#ifdef DEBUG_MEM
int dump_memory(void)
{
unsigned long tot = 0;
mb = mb->next;
}
}
-#endif
-/*
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+#else
+
+void *malloc_aux(size_t s, const char *file, int line)
+{
+ if (s > 50000000) {
+ log_error("Huge memory allocation (size %" PRIuPTR
+ ") rejected - metadata corruption?", s);
+ return 0;
+ }
+
+ return malloc(s);
+}
+
+#endif
#include <stdlib.h>
#include <string.h>
-#ifdef DEBUG_MEM
void *malloc_aux(size_t s, const char *file, int line);
+# define dbg_malloc(s) malloc_aux((s), __FILE__, __LINE__)
+
+#ifdef DEBUG_MEM
+
void free_aux(void *p);
void *realloc_aux(void *p, unsigned int s, const char *file, int line);
int dump_memory(void);
void bounds_check(void);
-# define dbg_malloc(s) malloc_aux((s), __FILE__, __LINE__)
# define dbg_free(p) free_aux(p)
# define dbg_realloc(p, s) realloc_aux(p, s, __FILE__, __LINE__)
+
#else
-# define dbg_malloc(s) malloc(s)
+
# define dbg_free(p) free(p)
# define dbg_realloc(p, s) realloc(p, s)
# define dump_memory()
# define bounds_check()
+
#endif
static inline char *dbg_strdup(const char *str)