-
+ 27C0BD5775F26059D615F270D9E74C36E5C55F72FBA1A95DE0E15F66DE1EEC857E8470AA62BDE31CBA19024F80A3CF8E8B487582703F142B3C167EB02B0A0E86eucrypt/mpi/include/memory.h(0 . 0)(1 . 103)
1120 /* memory.h - memory allocation
1121 * Modified by No Such Labs. (C) 2015. See README.
1122 *
1123 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
1124 * SHA256(gnupg-1.4.10.tar.gz):
1125 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
1126 * (C) 1994-2005 Free Software Foundation, Inc.
1127 *
1128 * This program is free software: you can redistribute it and/or modify
1129 * it under the terms of the GNU General Public License as published by
1130 * the Free Software Foundation, either version 3 of the License, or
1131 * (at your option) any later version.
1132 *
1133 * This program is distributed in the hope that it will be useful,
1134 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1135 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1136 * GNU General Public License for more details.
1137 *
1138 * You should have received a copy of the GNU General Public License
1139 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1140 */
1141
1142 #ifndef G10_MEMORY_H
1143 #define G10_MEMORY_H
1144
1145 #ifdef M_DEBUG
1146
1147 #ifndef STR
1148 #define STR(v) #v
1149 #endif
1150
1151 #define M_DBGINFO(a) __FUNCTION__ "["__FILE__ ":" STR(a) "]"
1152
1153 #define xmalloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) )
1154 #define xtrymalloc(n) m_debug_trymalloc ((n), M_DBGINFO( __LINE__ ))
1155 #define xmalloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) )
1156 #define xmalloc_secure(n) m_debug_alloc_secure(n), M_DBGINFO(__LINE__) )
1157 #define xmalloc_secure_clear(n) m_debug_alloc_secure_clear((n), M_DBGINFO(__LINE__) )
1158 #define xrealloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) )
1159 #define xfree(n) m_debug_free((n), M_DBGINFO(__LINE__) )
1160 #define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
1161 /*#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )*/
1162 #define xstrdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) )
1163 #define xtrystrdup(a) m_debug_trystrdup((a), M_DBGINFO(__LINE__) )
1164
1165 void *m_debug_alloc( size_t n, const char *info );
1166 void *m_debug_trymalloc (size_t n, const char *info);
1167 void *m_debug_alloc_clear( size_t n, const char *info );
1168 void *m_debug_alloc_secure( size_t n, const char *info );
1169 void *m_debug_alloc_secure_clear( size_t n, const char *info );
1170 void *m_debug_realloc( void *a, size_t n, const char *info );
1171 void m_debug_free( void *p, const char *info );
1172 void m_debug_check( const void *a, const char *info );
1173 /*void *m_debug_copy( const void *a, const char *info );*/
1174 char *m_debug_strdup( const char *a, const char *info );
1175 char *m_debug_trystrdup (const char *a, const char *info);
1176
1177 #else
1178 void *xmalloc( size_t n );
1179 void *xtrymalloc (size_t n);
1180 void *xmalloc_clear( size_t n );
1181 void *xmalloc_secure( size_t n );
1182 void *xmalloc_secure_clear( size_t n );
1183 void *xrealloc( void *a, size_t n );
1184 void xfree( void *p );
1185 void m_check( const void *a );
1186 /*void *m_copy( const void *a );*/
1187 char *xstrdup( const char * a);
1188 char *xtrystrdup (const char *a);
1189 #endif
1190
1191 size_t m_size( const void *a );
1192 void m_print_stats(const char *prefix);
1193
1194 /* The follwing functions should be preferred over xmalloc_clear. */
1195 void *xcalloc (size_t n, size_t m);
1196 void *xcalloc_secure (size_t n, size_t m);
1197
1198
1199 /*-- secmem.c --*/
1200 int secmem_init( size_t npool );
1201 void secmem_term( void );
1202 void *secmem_malloc( size_t size );
1203 void *secmexrealloc( void *a, size_t newsize );
1204 void secmem_free( void *a );
1205 int m_is_secure( const void *p );
1206 void secmem_dump_stats(void);
1207 void secmem_set_flags( unsigned flags );
1208 unsigned secmem_get_flags(void);
1209
1210
1211 #define DBG_MEMORY memory_debug_mode
1212 #define DBG_MEMSTAT memory_stat_debug_mode
1213
1214 #ifndef EXTERN_UNLESS_MAIN_MODULE
1215 #define EXTERN_UNLESS_MAIN_MODULE
1216 #endif
1217 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
1218 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
1219
1220
1221
1222 #endif /*G10_MEMORY_H*/