1 2 /*--------------------------------------------------------------------*/ 3 /*--- Misc simple stuff lacking a better home. misc.c ---*/ 4 /*--------------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2008-2010 OpenWorks LLP 11 info (at) open-works.co.uk 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License as 15 published by the Free Software Foundation; either version 2 of the 16 License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26 02111-1307, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29 30 Neither the names of the U.S. Department of Energy nor the 31 University of California nor the names of its contributors may be 32 used to endorse or promote products derived from this software 33 without prior written permission. 34 */ 35 36 #include "pub_core_basics.h" 37 #include "pub_core_libcbase.h" 38 #include "pub_core_libcassert.h" 39 #include "pub_core_mallocfree.h" 40 #include "pub_core_xarray.h" 41 42 #include "priv_misc.h" /* self */ 43 44 45 void* ML_(dinfo_zalloc) ( HChar* cc, SizeT szB ) { 46 void* v; 47 vg_assert(szB > 0); 48 v = VG_(arena_malloc)( VG_AR_DINFO, cc, szB ); 49 vg_assert(v); 50 VG_(memset)(v, 0, szB); 51 return v; 52 } 53 54 void ML_(dinfo_free) ( void* v ) { 55 VG_(arena_free)( VG_AR_DINFO, v ); 56 } 57 58 UChar* ML_(dinfo_strdup) ( HChar* cc, const UChar* str ) { 59 return VG_(arena_strdup)( VG_AR_DINFO, cc, str ); 60 } 61 62 UChar* ML_(dinfo_memdup)( HChar* cc, UChar* str, SizeT nStr ) { 63 UChar* dst = VG_(arena_malloc)( VG_AR_DINFO, cc, nStr ); 64 tl_assert(dst); 65 VG_(memcpy)(dst, str, nStr); 66 return dst; 67 } 68 69 70 /*--------------------------------------------------------------------*/ 71 /*--- end misc.c ---*/ 72 /*--------------------------------------------------------------------*/ 73