1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00
gnupg/include/memory.h

85 lines
2.9 KiB
C
Raw Normal View History

1997-11-18 15:06:00 +01:00
/* memory.h - memory allocation
1998-06-16 17:13:28 +02:00
* Copyright (C) 1998 Free Software Foundation, Inc.
1997-11-18 15:06:00 +01:00
*
1998-06-16 17:13:28 +02:00
* This file is part of GNUPG.
1997-11-18 15:06:00 +01:00
*
1998-06-16 17:13:28 +02:00
* GNUPG is free software; you can redistribute it and/or modify
1997-11-18 15:06:00 +01:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
1998-06-16 17:13:28 +02:00
* GNUPG is distributed in the hope that it will be useful,
1997-11-18 15:06:00 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef G10_MEMORY_H
#define G10_MEMORY_H
#ifdef M_DEBUG
#ifndef STR
#define STR(v) #v
#endif
#define M_DBGINFO(a) __FUNCTION__ "["__FILE__ ":" STR(a) "]"
#define m_alloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) )
#define m_alloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) )
#define m_alloc_secure(n) m_debug_alloc((n), M_DBGINFO(__LINE__) )
#define m_alloc_secure_clear(n) m_debug_alloc((n), M_DBGINFO(__LINE__) )
#define m_realloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) )
#define m_free(n) m_debug_free((n), M_DBGINFO(__LINE__) )
#define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
1998-02-27 18:51:28 +01:00
/*#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )*/
1997-12-12 13:03:58 +01:00
#define m_strdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) )
1997-11-18 15:06:00 +01:00
void *m_debug_alloc( size_t n, const char *info );
void *m_debug_alloc_clear( size_t n, const char *info );
void *m_debug_alloc_secure( size_t n, const char *info );
void *m_debug_alloc_secure_clear( size_t n, const char *info );
void *m_debug_realloc( void *a, size_t n, const char *info );
void m_debug_free( void *p, const char *info );
void m_debug_check( const void *a, const char *info );
1998-02-27 18:51:28 +01:00
/*void *m_debug_copy( const void *a, const char *info );*/
1997-12-12 13:03:58 +01:00
char *m_debug_strdup( const char *a, const char *info );
1997-11-18 15:06:00 +01:00
#else
void *m_alloc( size_t n );
void *m_alloc_clear( size_t n );
void *m_alloc_secure( size_t n );
void *m_alloc_secure_clear( size_t n );
void *m_realloc( void *a, size_t n );
void m_free( void *p );
void m_check( const void *a );
1998-02-27 18:51:28 +01:00
/*void *m_copy( const void *a );*/
1997-12-12 13:03:58 +01:00
char *m_strdup( const char * a);
1997-11-18 15:06:00 +01:00
#endif
size_t m_size( const void *a );
1998-10-12 22:16:38 +02:00
void m_print_stats(const char *prefix);
1997-11-18 15:06:00 +01:00
1998-01-28 17:09:43 +01:00
/*-- secmem.c --*/
void secmem_init( size_t npool );
void secmem_term( void );
void *secmem_malloc( size_t size );
1998-02-27 18:51:28 +01:00
void *secmem_realloc( void *a, size_t newsize );
1998-01-28 17:09:43 +01:00
void secmem_free( void *a );
1998-02-27 18:51:28 +01:00
int m_is_secure( const void *p );
1998-01-28 17:09:43 +01:00
void secmem_dump_stats(void);
1998-02-12 00:22:09 +01:00
void secmem_set_flags( unsigned flags );
unsigned secmem_get_flags(void);
1998-01-28 17:09:43 +01:00
1997-11-18 15:06:00 +01:00
#define DBG_MEMORY memory_debug_mode
#define DBG_MEMSTAT memory_stat_debug_mode
int memory_debug_mode;
int memory_stat_debug_mode;
1998-01-28 17:09:43 +01:00
1997-11-18 15:06:00 +01:00
#endif /*G10_MEMORY_H*/