Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:31

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- MallocFree: high-level memory management.                    ---*/
0004 /*---                                        pub_tool_mallocfree.h ---*/
0005 /*--------------------------------------------------------------------*/
0006 
0007 /*
0008    This file is part of Valgrind, a dynamic binary instrumentation
0009    framework.
0010 
0011    Copyright (C) 2000-2017 Julian Seward
0012       jseward@acm.org
0013 
0014    This program is free software; you can redistribute it and/or
0015    modify it under the terms of the GNU General Public License as
0016    published by the Free Software Foundation; either version 2 of the
0017    License, or (at your option) any later version.
0018 
0019    This program is distributed in the hope that it will be useful, but
0020    WITHOUT ANY WARRANTY; without even the implied warranty of
0021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0022    General Public License for more details.
0023 
0024    You should have received a copy of the GNU General Public License
0025    along with this program; if not, see <http://www.gnu.org/licenses/>.
0026 
0027    The GNU General Public License is contained in the file COPYING.
0028 */
0029 
0030 #ifndef __PUB_TOOL_MALLOCFREE_H
0031 #define __PUB_TOOL_MALLOCFREE_H
0032 
0033 #include "pub_tool_basics.h"   // SizeT
0034 
0035 // These can be for allocating memory used by tools.
0036 // Nb: the allocators *always succeed* -- they never return NULL (Valgrind
0037 // will abort if they can't allocate the memory).
0038 // The 'cc' is a string that identifies the allocation point.  It's used when
0039 // --profile-heap=yes is specified.
0040 extern void* VG_(malloc)         ( const HChar* cc, SizeT nbytes );
0041 extern void  VG_(free)           ( void* p );
0042 extern void* VG_(calloc)         ( const HChar* cc, SizeT n, SizeT bytes_per_elem );
0043 extern void*  VG_(realloc)       ( const HChar* cc, void* p, SizeT size );
0044 extern void   VG_(realloc_shrink)( void* ptr, SizeT size );
0045 extern HChar* VG_(strdup)        ( const HChar* cc, const HChar* s );
0046 
0047 // TODO: move somewhere else
0048 // Call here to bomb the system when out of memory (mmap anon fails)
0049 __attribute__((noreturn))
0050 extern void VG_(out_of_memory_NORETURN) ( const HChar* who, SizeT szB );
0051 
0052 // VG_(perm_malloc) is for allocating small blocks which are
0053 // never released. The overhead for such blocks is minimal.
0054 // VG_(perm_malloc) returns memory which is (at least) aligned
0055 // on a multiple of align.
0056 // Use the macro vg_alignof (type) to get a safe alignment for a type.
0057 // No other function can be used on these permanently allocated blocks.
0058 // In particular, do *not* call VG_(free) or VG_(realloc).
0059 // Technically, these blocks will be returned from big superblocks
0060 // only containing such permanently allocated blocks.
0061 // Note that there is no cc cost centre : all such blocks will be
0062 // regrouped under the "perm_alloc" cost centre.
0063 extern void* VG_(perm_malloc)    ( SizeT nbytes, Int align );
0064 
0065 #endif   // __PUB_TOOL_MALLOCFREE_H
0066 
0067 /*--------------------------------------------------------------------*/
0068 /*--- end                                                          ---*/
0069 /*--------------------------------------------------------------------*/
0070