2001-08-21 16:56:08 +04:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
* Copyright ( C ) 2004 Red Hat , Inc . All rights reserved .
2001-08-21 16:56:08 +04:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
*
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
* of the GNU General Public License v .2 .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
2001-08-21 16:56:08 +04:00
*/
2001-09-25 16:49:28 +04:00
# ifndef _LVM_DBG_MALLOC_H
# define _LVM_DBG_MALLOC_H
2001-08-21 16:56:08 +04:00
2003-03-24 21:08:53 +03:00
# include "lvm-types.h"
2001-12-12 19:25:53 +03:00
# include <stdlib.h>
2002-01-16 15:02:06 +03:00
# include <string.h>
2001-10-02 02:12:10 +04:00
2001-09-27 14:01:17 +04:00
void * malloc_aux ( size_t s , const char * file , int line ) ;
2004-11-25 00:34:56 +03:00
# define dbg_malloc(s) malloc_aux((s), __FILE__, __LINE__)
# ifdef DEBUG_MEM
2001-08-21 16:56:08 +04:00
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 ) ;
2003-04-15 17:24:42 +04:00
# define dbg_free(p) free_aux(p)
# define dbg_realloc(p, s) realloc_aux(p, s, __FILE__, __LINE__)
2004-11-25 00:34:56 +03:00
2001-08-21 16:56:08 +04:00
# else
2004-11-25 00:34:56 +03:00
2003-04-15 17:24:42 +04:00
# define dbg_free(p) free(p)
# define dbg_realloc(p, s) realloc(p, s)
# define dump_memory()
# define bounds_check()
2004-11-25 00:34:56 +03:00
2001-08-21 16:56:08 +04:00
# endif
2001-12-13 03:07:29 +03:00
static inline char * dbg_strdup ( const char * str )
{
char * ret = dbg_malloc ( strlen ( str ) + 1 ) ;
if ( ret )
strcpy ( ret , str ) ;
2001-08-21 16:56:08 +04:00
2001-12-13 03:07:29 +03:00
return ret ;
}
# endif