~ubuntu-branches/ubuntu/dapper/gnupg2/dapper

« back to all changes in this revision

Viewing changes to include/memory.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
ImportĀ upstreamĀ versionĀ 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* memory.h - memory allocation
 
2
 *      Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GNUPG.
 
5
 *
 
6
 * GNUPG is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * GNUPG is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 */
 
20
 
 
21
#ifndef G10_MEMORY_H
 
22
#define G10_MEMORY_H
 
23
 
 
24
#ifdef M_DEBUG
 
25
#ifndef STR
 
26
#define STR(v) #v
 
27
#endif
 
28
#ifndef __riscos__
 
29
#define M_DBGINFO(a)        __FUNCTION__ "["__FILE__ ":"  STR(a) "]"
 
30
#else /* __riscos__ */
 
31
#define M_DBGINFO(a)         "["__FILE__ ":"  STR(a) "]"
 
32
#endif /* __riscos__ */
 
33
#define m_alloc(n)              m_debug_alloc((n), M_DBGINFO( __LINE__ ) )
 
34
#define m_alloc_clear(n)        m_debug_alloc_clear((n), M_DBGINFO(__LINE__) )
 
35
#define m_alloc_secure(n)       m_debug_alloc((n), M_DBGINFO(__LINE__) )
 
36
#define m_alloc_secure_clear(n) m_debug_alloc_secure_clear((n), M_DBGINFO(__LINE__) )
 
37
#define m_realloc(n,m)          m_debug_realloc((n),(m), M_DBGINFO(__LINE__) )
 
38
#define m_free(n)               m_debug_free((n), M_DBGINFO(__LINE__) )
 
39
#define m_check(n)              m_debug_check((n), M_DBGINFO(__LINE__) )
 
40
/*#define m_copy(a)               m_debug_copy((a), M_DBGINFO(__LINE__) )*/
 
41
#define m_strdup(a)             m_debug_strdup((a), M_DBGINFO(__LINE__) )
 
42
 
 
43
void *m_debug_alloc( size_t n, const char *info );
 
44
void *m_debug_alloc_clear( size_t n, const char *info  );
 
45
void *m_debug_alloc_secure( size_t n, const char *info  );
 
46
void *m_debug_alloc_secure_clear( size_t n, const char *info  );
 
47
void *m_debug_realloc( void *a, size_t n, const char *info  );
 
48
void m_debug_free( void *p, const char *info  );
 
49
void m_debug_check( const void *a, const char *info );
 
50
/*void *m_debug_copy( const void *a, const char *info );*/
 
51
char *m_debug_strdup( const char *a, const char *info );
 
52
 
 
53
#else
 
54
void *m_alloc( size_t n );
 
55
void *m_alloc_clear( size_t n );
 
56
void *m_alloc_secure( size_t n );
 
57
void *m_alloc_secure_clear( size_t n );
 
58
void *m_realloc( void *a, size_t n );
 
59
void m_free( void *p );
 
60
void m_check( const void *a );
 
61
/*void *m_copy( const void *a );*/
 
62
char *m_strdup( const char * a);
 
63
#endif
 
64
 
 
65
size_t m_size( const void *a );
 
66
void m_print_stats(const char *prefix);
 
67
 
 
68
/*-- secmem.c --*/
 
69
void secmem_init( size_t npool );
 
70
void secmem_term( void );
 
71
void *secmem_malloc( size_t size );
 
72
void *secmem_realloc( void *a, size_t newsize );
 
73
void secmem_free( void *a );
 
74
int  m_is_secure( const void *p );
 
75
void secmem_dump_stats(void);
 
76
void secmem_set_flags( unsigned flags );
 
77
unsigned secmem_get_flags(void);
 
78
 
 
79
 
 
80
#define DBG_MEMORY    memory_debug_mode
 
81
#define DBG_MEMSTAT   memory_stat_debug_mode
 
82
 
 
83
#ifndef EXTERN_UNLESS_MAIN_MODULE
 
84
#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
 
85
#define EXTERN_UNLESS_MAIN_MODULE extern
 
86
#else
 
87
#define EXTERN_UNLESS_MAIN_MODULE 
 
88
#endif
 
89
#endif
 
90
EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
 
91
EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
 
92
 
 
93
#endif /*G10_MEMORY_H*/