1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/lib/mm/dbg_malloc.h

43 lines
899 B
C
Raw Normal View History

/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
*/
2001-09-25 16:49:28 +04:00
#ifndef _LVM_DBG_MALLOC_H
#define _LVM_DBG_MALLOC_H
2001-12-12 19:25:53 +03:00
#include <stdlib.h>
2002-01-16 15:02:06 +03:00
#include <string.h>
#include <sys/types.h>
#ifdef DEBUG_MEM
2001-09-27 14:01:17 +04:00
void *malloc_aux(size_t s, const char *file, int line);
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)
{
char *ret = dbg_malloc(strlen(str) + 1);
if (ret)
strcpy(ret, str);
return ret;
}
#endif