-
+ 27C0BD5775F26059D615F270D9E74C36E5C55F72FBA1A95DE0E15F66DE1EEC857E8470AA62BDE31CBA19024F80A3CF8E8B487582703F142B3C167EB02B0A0E86
smg_comms/mpi/include/memory.h
(0 . 0)(1 . 103)
1852 /* memory.h - memory allocation
1853 * Modified by No Such Labs. (C) 2015. See README.
1854 *
1855 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
1856 * SHA256(gnupg-1.4.10.tar.gz):
1857 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
1858 * (C) 1994-2005 Free Software Foundation, Inc.
1859 *
1860 * This program is free software: you can redistribute it and/or modify
1861 * it under the terms of the GNU General Public License as published by
1862 * the Free Software Foundation, either version 3 of the License, or
1863 * (at your option) any later version.
1864 *
1865 * This program is distributed in the hope that it will be useful,
1866 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1867 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1868 * GNU General Public License for more details.
1869 *
1870 * You should have received a copy of the GNU General Public License
1871 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1872 */
1873
1874 #ifndef G10_MEMORY_H
1875 #define G10_MEMORY_H
1876
1877 #ifdef M_DEBUG
1878
1879 #ifndef STR
1880 #define STR(v) #v
1881 #endif
1882
1883 #define M_DBGINFO(a) __FUNCTION__ "["__FILE__ ":" STR(a) "]"
1884
1885 #define xmalloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) )
1886 #define xtrymalloc(n) m_debug_trymalloc ((n), M_DBGINFO( __LINE__ ))
1887 #define xmalloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) )
1888 #define xmalloc_secure(n) m_debug_alloc_secure(n), M_DBGINFO(__LINE__) )
1889 #define xmalloc_secure_clear(n) m_debug_alloc_secure_clear((n), M_DBGINFO(__LINE__) )
1890 #define xrealloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) )
1891 #define xfree(n) m_debug_free((n), M_DBGINFO(__LINE__) )
1892 #define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
1893 /*#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )*/
1894 #define xstrdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) )
1895 #define xtrystrdup(a) m_debug_trystrdup((a), M_DBGINFO(__LINE__) )
1896
1897 void *m_debug_alloc( size_t n, const char *info );
1898 void *m_debug_trymalloc (size_t n, const char *info);
1899 void *m_debug_alloc_clear( size_t n, const char *info );
1900 void *m_debug_alloc_secure( size_t n, const char *info );
1901 void *m_debug_alloc_secure_clear( size_t n, const char *info );
1902 void *m_debug_realloc( void *a, size_t n, const char *info );
1903 void m_debug_free( void *p, const char *info );
1904 void m_debug_check( const void *a, const char *info );
1905 /*void *m_debug_copy( const void *a, const char *info );*/
1906 char *m_debug_strdup( const char *a, const char *info );
1907 char *m_debug_trystrdup (const char *a, const char *info);
1908
1909 #else
1910 void *xmalloc( size_t n );
1911 void *xtrymalloc (size_t n);
1912 void *xmalloc_clear( size_t n );
1913 void *xmalloc_secure( size_t n );
1914 void *xmalloc_secure_clear( size_t n );
1915 void *xrealloc( void *a, size_t n );
1916 void xfree( void *p );
1917 void m_check( const void *a );
1918 /*void *m_copy( const void *a );*/
1919 char *xstrdup( const char * a);
1920 char *xtrystrdup (const char *a);
1921 #endif
1922
1923 size_t m_size( const void *a );
1924 void m_print_stats(const char *prefix);
1925
1926 /* The follwing functions should be preferred over xmalloc_clear. */
1927 void *xcalloc (size_t n, size_t m);
1928 void *xcalloc_secure (size_t n, size_t m);
1929
1930
1931 /*-- secmem.c --*/
1932 int secmem_init( size_t npool );
1933 void secmem_term( void );
1934 void *secmem_malloc( size_t size );
1935 void *secmexrealloc( void *a, size_t newsize );
1936 void secmem_free( void *a );
1937 int m_is_secure( const void *p );
1938 void secmem_dump_stats(void);
1939 void secmem_set_flags( unsigned flags );
1940 unsigned secmem_get_flags(void);
1941
1942
1943 #define DBG_MEMORY memory_debug_mode
1944 #define DBG_MEMSTAT memory_stat_debug_mode
1945
1946 #ifndef EXTERN_UNLESS_MAIN_MODULE
1947 #define EXTERN_UNLESS_MAIN_MODULE
1948 #endif
1949 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
1950 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
1951
1952
1953
1954 #endif /*G10_MEMORY_H*/