![]() |
|
|||
File indexing completed on 2025-09-16 09:11:10
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 // Provide the VKI errno if possible (normally the result of sr_Err), 0050 // may be zero if unknown. 0051 __attribute__((noreturn)) 0052 extern void VG_(out_of_memory_NORETURN) ( const HChar* who, SizeT szB, 0053 UWord err ); 0054 0055 // VG_(perm_malloc) is for allocating small blocks which are 0056 // never released. The overhead for such blocks is minimal. 0057 // VG_(perm_malloc) returns memory which is (at least) aligned 0058 // on a multiple of align. 0059 // Use the macro vg_alignof (type) to get a safe alignment for a type. 0060 // No other function can be used on these permanently allocated blocks. 0061 // In particular, do *not* call VG_(free) or VG_(realloc). 0062 // Technically, these blocks will be returned from big superblocks 0063 // only containing such permanently allocated blocks. 0064 // Note that there is no cc cost centre : all such blocks will be 0065 // regrouped under the "perm_alloc" cost centre. 0066 extern void* VG_(perm_malloc) ( SizeT nbytes, Int align ); 0067 0068 #endif // __PUB_TOOL_MALLOCFREE_H 0069 0070 /*--------------------------------------------------------------------*/ 0071 /*--- end ---*/ 0072 /*--------------------------------------------------------------------*/ 0073
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |