Char/HChar and constness fixes. Mostly cost center
authorflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sat, 27 Oct 2012 23:07:42 +0000 (23:07 +0000)
committerflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sat, 27 Oct 2012 23:07:42 +0000 (23:07 +0000)
on allocators which is always a const HChar *

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13089 a5019735-40e9-0310-863c-91ae7b9d1cf9

30 files changed:
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/misc.c
coregrind/m_debuginfo/priv_misc.h
coregrind/m_errormgr.c
coregrind/m_gdbserver/m_gdbserver.c
coregrind/m_mallocfree.c
coregrind/m_oset.c
coregrind/m_poolalloc.c
coregrind/m_redir.c
coregrind/m_sparsewa.c
coregrind/m_transtab.c
coregrind/m_wordfm.c
coregrind/m_xarray.c
coregrind/pub_core_mallocfree.h
drd/tests/unit_bitmap.c
drd/tests/unit_vc.c
exp-sgcheck/sg_main.c
helgrind/hg_basics.c
helgrind/hg_basics.h
helgrind/hg_wordset.c
helgrind/hg_wordset.h
include/pub_tool_mallocfree.h
include/pub_tool_oset.h
include/pub_tool_poolalloc.h
include/pub_tool_sparsewa.h
include/pub_tool_wordfm.h
include/pub_tool_xarray.h
memcheck/mc_leakcheck.c
memcheck/mc_main.c
memcheck/tests/unit_oset.c

index dc4f2053ef8e9f63d2982cb526f83bd8e1b2b547..2bf206beb926f8b8f94769ea3d175b22052bdf59 100644 (file)
@@ -1044,7 +1044,7 @@ void VG_(di_notify_pdb_debuginfo)( Int fd_obj, Addr avma_obj,
 {
    Int    i, r, sz_exename;
    ULong  obj_mtime, pdb_mtime;
-   Char   exename[VKI_PATH_MAX];
+   HChar  exename[VKI_PATH_MAX];
    Char*  pdbname = NULL;
    Char*  dot;
    SysRes sres;
index 880a2ccb3287176bba08b8df34091ca029ea41e3..a003a21052c4e0caa996c4ad39aed483d06379fe 100644 (file)
@@ -42,7 +42,7 @@
 #include "priv_misc.h"            /* self */
 
 
-void* ML_(dinfo_zalloc) ( HChar* cc, SizeT szB ) {
+void* ML_(dinfo_zalloc) ( const HChar* cc, SizeT szB ) {
    void* v;
    vg_assert(szB > 0);
    v = VG_(arena_malloc)( VG_AR_DINFO, cc, szB );
@@ -55,11 +55,11 @@ void ML_(dinfo_free) ( void* v ) {
    VG_(arena_free)( VG_AR_DINFO, v );
 }
 
-UChar* ML_(dinfo_strdup) ( HChar* cc, const UChar* str ) {
+UChar* ML_(dinfo_strdup) ( const HChar* cc, const UChar* str ) {
    return VG_(arena_strdup)( VG_AR_DINFO, cc, str );
 }
 
-UChar* ML_(dinfo_memdup) ( HChar* cc, UChar* str, SizeT nStr ) {
+UChar* ML_(dinfo_memdup) ( const HChar* cc, UChar* str, SizeT nStr ) {
    UChar* dst = VG_(arena_malloc)( VG_AR_DINFO, cc, nStr );
    tl_assert(dst);
    VG_(memcpy)(dst, str, nStr);
index 48de94bc6197ce8eafa441fa2edc82b0accfc602..6c2e66c9e7cd706c273eed98014e90be4001ec63 100644 (file)
 
 
 /* Allocate(zeroed), free, strdup, memdup, all in VG_AR_DINFO. */
-void*  ML_(dinfo_zalloc)( HChar* cc, SizeT szB );
+void*  ML_(dinfo_zalloc)( const HChar* cc, SizeT szB );
 void   ML_(dinfo_free)( void* v );
-UChar* ML_(dinfo_strdup)( HChar* cc, const UChar* str );
-UChar* ML_(dinfo_memdup)( HChar* cc, UChar* str, SizeT nStr );
+UChar* ML_(dinfo_strdup)( const HChar* cc, const UChar* str );
+UChar* ML_(dinfo_memdup)( const HChar* cc, UChar* str, SizeT nStr );
 
 /* Extract (possibly unaligned) data of various sizes from a buffer. */
 Short ML_(read_Short)( UChar* data );
index 84bf89187b0a4ff86622d80b1a4716d6d22935c9..a2520801bcc638e9f59344e6b53a755fadd0b0dc 100644 (file)
@@ -346,7 +346,7 @@ static void printSuppForIp_nonXML(UInt n, Addr ip, void* textV)
 */
 static void gen_suppression(Error* err)
 {
-   Char        xtra[256]; /* assumed big enough (is overrun-safe) */
+   HChar       xtra[256]; /* assumed big enough (is overrun-safe) */
    Bool        anyXtra;
    const HChar* name;
    ExeContext* ec;
index 388abafd63ab5ffa17ac2aff000d5da2d7496337..212859e6f8550d545dcc17e47781e7303c8edfa1 100644 (file)
@@ -159,7 +159,7 @@ static int gdbserver_called = 0;
 static int gdbserver_exited = 0;
 
 /* alloc and free functions for xarray and similar. */
-static void* gs_alloc (HChar* cc, SizeT sz)
+static void* gs_alloc (const HChar* cc, SizeT sz)
 {
    void* res = VG_(arena_malloc)(VG_AR_CORE, cc, sz);
    vg_assert (res);
index e64b75ba99e10e05f18099b66a5a37adc1ed40da..880771335f6334e81292f8056fa27527b0e49ae2 100644 (file)
@@ -191,7 +191,7 @@ typedef
 // elastic, in that it can be bigger than asked-for to ensure alignment.
 typedef
    struct {
-      Char*        name;
+      const HChar* name;
       Bool         clientmem;        // Allocates in the client address space?
       SizeT        rz_szB;           // Red zone size in bytes
       SizeT        min_sblock_szB;   // Minimum superblock size in bytes
@@ -424,18 +424,18 @@ Block* get_next_b ( Block* b )
 
 // Set and get the cost-center field of a block.
 static __inline__
-void set_cc ( Block* b, HChar* cc )
+void set_cc ( Block* b, const HChar* cc )
 { 
    UByte* b2 = (UByte*)b;
    vg_assert( VG_(clo_profile_heap) );
-   *(HChar**)&b2[0] = cc;
+   *(const HChar**)&b2[0] = cc;
 }
 static __inline__
-HChar* get_cc ( Block* b )
+const HChar* get_cc ( Block* b )
 {
    UByte* b2 = (UByte*)b;
    vg_assert( VG_(clo_profile_heap) );
-   return *(HChar**)&b2[0];
+   return *(const HChar**)&b2[0];
 }
 
 //---------------------------------------------------------------------------
@@ -509,7 +509,7 @@ SizeT VG_(malloc_effective_client_redzone_size)(void)
 // It might be overriden by VG_(clo_redzone_size) or VG_(clo_core_redzone_size).
 // it might be made bigger to ensure that VG_MIN_MALLOC_SZB is observed.
 static
-void arena_init ( ArenaId aid, Char* name, SizeT rz_szB,
+void arena_init ( ArenaId aid, const HChar* name, SizeT rz_szB,
                   SizeT min_sblock_szB, SizeT min_unsplittable_sblock_szB )
 {
    SizeT  i;
@@ -702,7 +702,7 @@ void ensure_mm_init ( ArenaId aid )
 /*------------------------------------------------------------*/
 
 __attribute__((noreturn))
-void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB )
+void VG_(out_of_memory_NORETURN) ( const HChar* who, SizeT szB )
 {
    static Int outputTrial = 0;
    // We try once to output the full memory state followed by the below message.
@@ -711,7 +711,7 @@ void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB )
    // And then we abandon.
    
    ULong tot_alloc = VG_(am_get_anonsize_total)();
-   Char* s1 = 
+   const HChar* s1 = 
       "\n"
       "    Valgrind's memory management: out of memory:\n"
       "       %s's request for %llu bytes failed.\n"
@@ -1272,7 +1272,11 @@ static void sanity_check_malloc_arena ( ArenaId aid )
 
 #define N_AN_CCS 1000
 
-typedef struct { ULong nBytes; ULong nBlocks; HChar* cc; } AnCC;
+typedef struct {
+   ULong nBytes;
+   ULong nBlocks;
+   const HChar* cc;
+} AnCC;
 
 static AnCC anCCs[N_AN_CCS];
 
@@ -1292,7 +1296,7 @@ static void cc_analyse_alloc_arena ( ArenaId aid )
    Bool        thisFree, lastWasFree;
    SizeT       b_bszB;
 
-   HChar* cc;
+   const HChar* cc;
    UInt n_ccs = 0;
    //return;
    a = arenaId_to_ArenaP(aid);
@@ -1480,7 +1484,7 @@ SizeT align_req_pszB ( SizeT req_pszB )
    return ((req_pszB + n) & (~n));
 }
 
-void* VG_(arena_malloc) ( ArenaId aid, HChar* cc, SizeT req_pszB )
+void* VG_(arena_malloc) ( ArenaId aid, const HChar* cc, SizeT req_pszB )
 {
    SizeT       req_bszB, frag_bszB, b_bszB;
    UInt        lno, i;
@@ -1953,7 +1957,7 @@ void VG_(arena_free) ( ArenaId aid, void* ptr )
    .    .               .   .   .               .   .
 
 */
-void* VG_(arena_memalign) ( ArenaId aid, HChar* cc, 
+void* VG_(arena_memalign) ( ArenaId aid, const HChar* cc, 
                             SizeT req_alignB, SizeT req_pszB )
 {
    SizeT  base_pszB_req, base_pszB_act, frag_bszB;
@@ -2148,11 +2152,11 @@ void VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi )
 /*--- Services layered on top of malloc/free.              ---*/
 /*------------------------------------------------------------*/
 
-void* VG_(arena_calloc) ( ArenaId aid, HChar* cc,
+void* VG_(arena_calloc) ( ArenaId aid, const HChar* cc,
                           SizeT nmemb, SizeT bytes_per_memb )
 {
    SizeT  size;
-   UChar* p;
+   void*  p;
 
    size = nmemb * bytes_per_memb;
    vg_assert(size >= nmemb && size >= bytes_per_memb);// check against overflow
@@ -2165,12 +2169,12 @@ void* VG_(arena_calloc) ( ArenaId aid, HChar* cc,
 }
 
 
-void* VG_(arena_realloc) ( ArenaId aid, HChar* cc, 
+void* VG_(arena_realloc) ( ArenaId aid, const HChar* cc, 
                            void* ptr, SizeT req_pszB )
 {
    Arena* a;
    SizeT  old_pszB;
-   UChar  *p_new;
+   void*  p_new;
    Block* b;
 
    ensure_mm_init(aid);
@@ -2208,7 +2212,7 @@ void* VG_(arena_realloc) ( ArenaId aid, HChar* cc,
 
 
 /* Inline just for the wrapper VG_(strdup) below */
-__inline__ Char* VG_(arena_strdup) ( ArenaId aid, HChar* cc, 
+__inline__ Char* VG_(arena_strdup) ( ArenaId aid, const HChar* cc, 
                                      const Char* s )
 {
    Int   i;
@@ -2233,7 +2237,7 @@ __inline__ Char* VG_(arena_strdup) ( ArenaId aid, HChar* cc,
 
 // All just wrappers to avoid exposing arenas to tools.
 
-void* VG_(malloc) ( HChar* cc, SizeT nbytes )
+void* VG_(malloc) ( const HChar* cc, SizeT nbytes )
 {
    return VG_(arena_malloc) ( VG_AR_TOOL, cc, nbytes );
 }
@@ -2243,17 +2247,17 @@ void  VG_(free) ( void* ptr )
    VG_(arena_free) ( VG_AR_TOOL, ptr );
 }
 
-void* VG_(calloc) ( HChar* cc, SizeT nmemb, SizeT bytes_per_memb )
+void* VG_(calloc) ( const HChar* cc, SizeT nmemb, SizeT bytes_per_memb )
 {
    return VG_(arena_calloc) ( VG_AR_TOOL, cc, nmemb, bytes_per_memb );
 }
 
-void* VG_(realloc) ( HChar* cc, void* ptr, SizeT size )
+void* VG_(realloc) ( const HChar* cc, void* ptr, SizeT size )
 {
    return VG_(arena_realloc) ( VG_AR_TOOL, cc, ptr, size );
 }
 
-Char* VG_(strdup) ( HChar* cc, const Char* s )
+Char* VG_(strdup) ( const HChar* cc, const Char* s )
 {
    return VG_(arena_strdup) ( VG_AR_TOOL, cc, s ); 
 }
index acb724eb812db5bf670bcf6a8b70b6df09239024..8e45700de45aa36fe5209b50acf82ad723faf94f 100644 (file)
@@ -113,7 +113,7 @@ struct _OSet {
    SizeT       keyOff;     // key offset
    OSetCmp_t   cmp;        // compare a key and an element, or NULL
    OSetAlloc_t alloc;      // allocator
-   HChar* cc;              // cc for allocator
+   const HChar* cc;        // cc for allocator
    OSetFree_t  free;       // deallocator
    PoolAlloc*  node_pa;    // (optional) pool allocator for nodes.
    SizeT       maxEltSize; // for node_pa, must be > 0. Otherwise unused.
@@ -286,7 +286,7 @@ static inline Bool stackPop(AvlTree* t, AvlNode** n, Int* i)
 
 // The underscores avoid GCC complaints about overshadowing global names.
 AvlTree* VG_(OSetGen_Create)(PtrdiffT _keyOff, OSetCmp_t _cmp,
-                             OSetAlloc_t _alloc, HChar* _cc,
+                             OSetAlloc_t _alloc, const HChar* _cc,
                              OSetFree_t _free)
 {
    AvlTree* t;
@@ -315,7 +315,7 @@ AvlTree* VG_(OSetGen_Create)(PtrdiffT _keyOff, OSetCmp_t _cmp,
 }
 
 AvlTree* VG_(OSetGen_Create_With_Pool)(PtrdiffT _keyOff, OSetCmp_t _cmp,
-                                       OSetAlloc_t _alloc, HChar* _cc,
+                                       OSetAlloc_t _alloc, const HChar* _cc,
                                        OSetFree_t _free,
                                        SizeT _poolSize,
                                        SizeT _maxEltSize)
@@ -363,7 +363,7 @@ AvlTree* VG_(OSetGen_EmptyClone) (AvlTree* os)
    return t;
 }
 
-AvlTree* VG_(OSetWord_Create)(OSetAlloc_t _alloc, HChar* _cc, 
+AvlTree* VG_(OSetWord_Create)(OSetAlloc_t _alloc, const HChar* _cc, 
                               OSetFree_t _free)
 {
    return VG_(OSetGen_Create)(/*keyOff*/0, /*cmp*/NULL, _alloc, _cc, _free);
index a236a0b684edaf0cc5f4c18d6dd066b0fbc1ae33..e3b07fcf00fb41d266e5ffde339c173c51f2308f 100644 (file)
@@ -36,8 +36,8 @@ struct _PoolAlloc {
    UWord   nrRef;         /* nr reference to this pool allocator */
    UWord   elemSzB;       /* element size */
    UWord   nPerPool;      /* # elems per pool */
-   void*   (*alloc)(HChar*, SizeT); /* pool allocator */
-   HChar*  cc; /* pool allocator's cc */
+   void*   (*alloc)(const HChar*, SizeT); /* pool allocator */
+   const HChar*  cc; /* pool allocator's cc */
    void    (*free)(void*); /* pool allocator's free-er */
    /* XArray of void* (pointers to pools).  The pools themselves.
       Each element is a pointer to a block of size (elemSzB *
@@ -50,8 +50,8 @@ struct _PoolAlloc {
 
 PoolAlloc* VG_(newPA) ( UWord  elemSzB,
                         UWord  nPerPool,
-                        void*  (*alloc)(HChar*, SizeT),
-                        HChar* cc,
+                        void*  (*alloc)(const HChar*, SizeT),
+                        const  HChar* cc,
                         void   (*free_fn)(void*) )
 {
    PoolAlloc* pa;
index 43df9d22e948ff3e62c75271ab37a88f2854f1b3..1df8d96272bfb17280dd56c103647145ef876546 100644 (file)
@@ -302,13 +302,13 @@ static Addr iFuncWrapper;
 
 static void maybe_add_active ( Active /*by value; callee copies*/ );
 
-static void*  dinfo_zalloc(HChar* ec, SizeT);
+static void*  dinfo_zalloc(const HChar* ec, SizeT);
 static void   dinfo_free(void*);
-static HChar* dinfo_strdup(HChar* ec, HChar*);
+static HChar* dinfo_strdup(const HChar* ec, const HChar*);
 static Bool   is_plausible_guest_addr(Addr);
 
-static void   show_redir_state ( HChar* who );
-static void   show_active ( HChar* left, Active* act );
+static void   show_redir_state ( const HChar* who );
+static void   show_active ( const HChar* left, Active* act );
 
 static void   handle_maybe_load_notifier( const UChar* soname, 
                                                 HChar* symbol, Addr addr );
@@ -447,7 +447,7 @@ void VG_(redir_notify_new_DebugInfo)( DebugInfo* newdi )
             pointing to files inside the valgrind build directories. */
          struct vg_stat newdi_stat;
          SysRes newdi_res;
-         Char in_vglib_filename[VKI_PATH_MAX];
+         HChar in_vglib_filename[VKI_PATH_MAX];
          struct vg_stat in_vglib_stat;
          SysRes in_vglib_res;
 
@@ -1382,7 +1382,7 @@ void VG_(redir_initialise) ( void )
 /*--- MISC HELPERS                                         ---*/
 /*------------------------------------------------------------*/
 
-static void* dinfo_zalloc(HChar* ec, SizeT n) {
+static void* dinfo_zalloc(const HChar* ec, SizeT n) {
    void* p;
    vg_assert(n > 0);
    p = VG_(arena_malloc)(VG_AR_DINFO, ec, n);
@@ -1396,7 +1396,7 @@ static void dinfo_free(void* p) {
    return VG_(arena_free)(VG_AR_DINFO, p);
 }
 
-static HChar* dinfo_strdup(HChar* ec, HChar* str)
+static HChar* dinfo_strdup(const HChar* ec, const HChar* str)
 {
    return VG_(arena_strdup)(VG_AR_DINFO, ec, str);
 }
@@ -1574,7 +1574,7 @@ static void handle_require_text_symbols ( DebugInfo* di )
 /*--- SANITY/DEBUG                                         ---*/
 /*------------------------------------------------------------*/
 
-static void show_spec ( HChar* left, Spec* spec )
+static void show_spec ( const HChar* left, Spec* spec )
 {
    VG_(message)( Vg_DebugMsg, 
                  "%s%25s %30s %s-> (%04d.%d) 0x%08llx\n",
@@ -1585,7 +1585,7 @@ static void show_spec ( HChar* left, Spec* spec )
                  (ULong)spec->to_addr );
 }
 
-static void show_active ( HChar* left, Active* act )
+static void show_active ( const HChar* left, Active* act )
 {
    Bool ok;
    HChar name1[64] = "";
@@ -1604,7 +1604,7 @@ static void show_active ( HChar* left, Active* act )
                              (ULong)act->to_addr, name2 );
 }
 
-static void show_redir_state ( HChar* who )
+static void show_redir_state ( const HChar* who )
 {
    TopSpec* ts;
    Spec*    sp;
index 56cef89d32bdc22cd71e75c3f7f70276ba724a45..4ccb7a60836fe7d61658f7b02434b6c31b53cb9d 100644 (file)
@@ -79,8 +79,8 @@ typedef
    SWAStackElem;
 
 struct _SparseWA {
-   void*        (*alloc_nofail)(HChar*,SizeT);
-   HChar*       cc;
+   void*        (*alloc_nofail)(const HChar*,SizeT);
+   const HChar* cc;
    void         (*dealloc)(void*);
    LevelN*      root;
    SWAStackElem iterStack[8];
@@ -231,8 +231,8 @@ Bool VG_(nextIterSWA)( SparseWA* swa,
 }
 
 
-SparseWA* VG_(newSWA) ( void*(*alloc_nofail)(HChar* cc, SizeT), 
-                        HChar* cc,
+SparseWA* VG_(newSWA) ( void*(*alloc_nofail)(const HChar* cc, SizeT), 
+                        const HChar* cc,
                         void(*dealloc)(void*) )
 {
    SparseWA* swa;
index 6eb169c984372eb1163086947c5fd27ca0b5adbb..87cf7ec4b99d9cd5389e169e053ead4c496b2807 100644 (file)
@@ -422,7 +422,7 @@ static ULong n_disc_osize = 0;
 /*--- Misc                                                  ---*/
 /*-------------------------------------------------------------*/
 
-static void* ttaux_malloc ( HChar* tag, SizeT n )
+static void* ttaux_malloc ( const HChar* tag, SizeT n )
 {
    return VG_(arena_malloc)(VG_AR_TTAUX, tag, n);
 }
index f386ea8f454fe0c3c3c81223643df7d00bc241c7..c517fcbf89688dd6897f97b5e5abf323f2a8fa2d 100644 (file)
@@ -81,8 +81,8 @@ typedef
 
 struct _WordFM {
    AvlNode* root;
-   void*    (*alloc_nofail)( HChar*, SizeT );
-   HChar*   cc;
+   void*    (*alloc_nofail)( const HChar*, SizeT );
+   const HChar* cc;
    void     (*dealloc)(void*);
    Word     (*kCmp)(UWord,UWord);
    AvlNode* nodeStack[WFM_STKMAX]; // Iterator node stack
@@ -502,8 +502,8 @@ static
 AvlNode* avl_dopy ( AvlNode* nd, 
                     UWord(*dopyK)(UWord), 
                     UWord(*dopyV)(UWord),
-                    void*(alloc_nofail)(HChar*,SizeT),
-                    HChar* cc )
+                    void*(alloc_nofail)(const HChar*,SizeT),
+                    const HChar* cc )
 {
    AvlNode* nyu;
    if (! nd)
@@ -554,8 +554,8 @@ AvlNode* avl_dopy ( AvlNode* nd,
 
 /* Initialise a WordFM. */
 static void initFM ( WordFM* fm,
-                     void*   (*alloc_nofail)( HChar*, SizeT ),
-                     HChar*  cc,
+                     void*   (*alloc_nofail)( const HChar*, SizeT ),
+                     const HChar* cc,
                      void    (*dealloc)(void*),
                      Word    (*kCmp)(UWord,UWord) )
 {
@@ -576,8 +576,8 @@ static void initFM ( WordFM* fm,
    sections of the map, or the whole thing.  If kCmp is NULL then the
    ordering used is unsigned word ordering (UWord) on the key
    values. */
-WordFM* VG_(newFM) ( void* (*alloc_nofail)( HChar*, SizeT ),
-                     HChar* cc,
+WordFM* VG_(newFM) ( void* (*alloc_nofail)( const HChar*, SizeT ),
+                     const HChar* cc,
                      void  (*dealloc)(void*),
                      Word  (*kCmp)(UWord,UWord) )
 {
@@ -849,8 +849,8 @@ struct _WordBag {
    WordFM* fm; 
 };
 
-WordBag* VG_(newBag) ( void* (*alloc_nofail)( HChar*, SizeT ),
-                       HChar* cc,
+WordBag* VG_(newBag) ( void* (*alloc_nofail)( const HChar*, SizeT ),
+                       const HChar* cc,
                        void  (*dealloc)(void*) )
 {
    WordBag* bag = alloc_nofail(cc, sizeof(WordBag));
index bac4ab8e6b0f3423827e0e18414ed785395490e2..c784f90f4e65d1b59bfd0105d5a696c803b52556 100644 (file)
@@ -38,8 +38,8 @@
 /* See pub_tool_xarray.h for details of what this is all about. */
 
 struct _XArray {
-   void* (*alloc) ( HChar*, SizeT ); /* alloc fn (nofail) */
-   HChar* cc;                       /* cost centre for alloc */
+   void* (*alloc) ( const HChar*, SizeT ); /* alloc fn (nofail) */
+   const HChar* cc;                 /* cost centre for alloc */
    void  (*free) ( void* );         /* free fn */
    Int   (*cmpFn) ( void*, void* ); /* cmp fn (may be NULL) */
    Word  elemSzB;   /* element size in bytes */
@@ -50,8 +50,8 @@ struct _XArray {
 };
 
 
-XArray* VG_(newXA) ( void*(*alloc_fn)(HChar*,SizeT), 
-                     HChar* cc,
+XArray* VG_(newXA) ( void*(*alloc_fn)(const HChar*,SizeT), 
+                     const HChar* cc,
                      void(*free_fn)(void*),
                      Word elemSzB )
 {
@@ -79,11 +79,11 @@ XArray* VG_(newXA) ( void*(*alloc_fn)(HChar*,SizeT),
    return xa;
 }
 
-XArray* VG_(cloneXA)( HChar* cc, XArray* xao )
+XArray* VG_(cloneXA)( const HChar* cc, XArray* xao )
 {
    struct _XArray* xa = (struct _XArray*)xao;
    struct _XArray* nyu;
-   HChar* nyu_cc;
+   const HChar* nyu_cc;
    vg_assert(xa);
    vg_assert(xa->alloc);
    vg_assert(xa->free);
index 7cd9536d60490d12f220193da2b21ccd42dca573..f6270c8a30209193ead14b33af070febede5924c 100644 (file)
@@ -103,15 +103,15 @@ struct vg_mallinfo {
    int keepcost; /* top-most, releasable (via malloc_trim) space */
 };
 
-extern void* VG_(arena_malloc)  ( ArenaId arena, HChar* cc, SizeT nbytes );
+extern void* VG_(arena_malloc)  ( ArenaId arena, const HChar* cc, SizeT nbytes );
 extern void  VG_(arena_free)    ( ArenaId arena, void* ptr );
-extern void* VG_(arena_calloc)  ( ArenaId arena, HChar* cc,
+extern void* VG_(arena_calloc)  ( ArenaId arena, const HChar* cc,
                                   SizeT nmemb, SizeT bytes_per_memb );
-extern void* VG_(arena_realloc) ( ArenaId arena, HChar* cc,
+extern void* VG_(arena_realloc) ( ArenaId arena, const HChar* cc,
                                   void* ptr, SizeT size );
-extern void* VG_(arena_memalign)( ArenaId aid, HChar* cc,
+extern void* VG_(arena_memalign)( ArenaId aid, const HChar* cc,
                                   SizeT req_alignB, SizeT req_pszB );
-extern Char* VG_(arena_strdup)  ( ArenaId aid, HChar* cc, 
+extern Char* VG_(arena_strdup)  ( ArenaId aid, const HChar* cc, 
                                   const Char* s);
 
 extern SizeT VG_(arena_malloc_usable_size) ( ArenaId aid, void* payload );
index 29892e47c6487140f7e3ac4f15822ed169e41f62..f2474f5cc3fb0e5e24bb24d51e5edde170e8601a 100644 (file)
@@ -24,7 +24,7 @@
 
 /* Replacements for Valgrind core functionality. */
 
-void* VG_(malloc)(HChar* cc, SizeT nbytes)
+void* VG_(malloc)(const HChar* cc, SizeT nbytes)
 { return malloc(nbytes); }
 void  VG_(free)(void* p)
 { return free(p); }
index 1e0b984f86f937795abc915d840365b8b8f8a7dc..4364fda306fff5e135bc1a6b9ebb9bc4534fce12 100644 (file)
@@ -10,9 +10,9 @@
 
 /* Replacements for Valgrind core functionality. */
 
-void* VG_(malloc)(HChar* cc, SizeT nbytes)
+void* VG_(malloc)(const HChar* cc, SizeT nbytes)
 { return malloc(nbytes); }
-void* VG_(realloc)(HChar* cc, void* p, SizeT size)
+void* VG_(realloc)(const HChar* cc, void* p, SizeT size)
 { return realloc(p, size); }
 void  VG_(free)(void* p)
 { return free(p); }
index cefa31809c900bf5415f64c8c5925fa3cdc5546f..d250d0e987270dacdfd44c0552fe08d065988c07 100644 (file)
@@ -69,7 +69,7 @@ static inline Bool is_sane_TId ( ThreadId tid )
           && tid != VG_INVALID_THREADID;
 }
 
-static void* sg_malloc ( HChar* cc, SizeT n ) {
+static void* sg_malloc ( const HChar* cc, SizeT n ) {
    void* p;
    tl_assert(n > 0);
    p = VG_(malloc)( cc, n );
@@ -477,7 +477,7 @@ typedef
    }
    StackTreeNode;
 
-static void pp_StackTree ( WordFM* sitree, HChar* who )
+static void pp_StackTree ( WordFM* sitree, const HChar* who )
 {
    UWord keyW, valW;
    VG_(printf)("<<< BEGIN pp_StackTree %s\n", who );
@@ -637,7 +637,7 @@ static void GlobalTreeNode__pp ( GlobalTreeNode* nd ) {
 }
 
 static void GlobalTree__pp ( WordFM* /* of (GlobalTreeNode,void) */ gitree,
-                             HChar* who )
+                             const HChar* who )
 {
    UWord keyW, valW;
    GlobalTreeNode* nd;
@@ -1016,7 +1016,7 @@ static void QCache__invalidate ( QCache* qc ) {
    qc->nInUse = 0;
 }
 
-static void QCache__pp ( QCache* qc, HChar* who )
+static void QCache__pp ( QCache* qc, const HChar* who )
 {
    Word i;
    VG_(printf)("<<< QCache with %ld elements (%s)\n", qc->nInUse, who);
index fdb935d6f94d0075c09430626615a39a716a4fa4..00f4a8b136a5d13cc83e4f548033ef8ef029160d 100644 (file)
@@ -42,7 +42,7 @@
 /*--- Very basic stuff                                         ---*/
 /*----------------------------------------------------------------*/
 
-void* HG_(zalloc) ( HChar* cc, SizeT n )
+void* HG_(zalloc) ( const HChar* cc, SizeT n )
 {
    void* p;
    tl_assert(n > 0);
@@ -58,7 +58,7 @@ void HG_(free) ( void* p )
    VG_(free)(p);
 }
 
-Char* HG_(strdup) ( HChar* cc, const Char* s )
+Char* HG_(strdup) ( const HChar* cc, const Char* s )
 {
    return VG_(strdup)( cc, s );
 }
index aba074b20e58fe2bdab63316b818cc2ee1589445..6d9d5f45bb5970e589eb4ad187ffe159d54d6d5c 100644 (file)
@@ -39,9 +39,9 @@
 
 #define HG_(str) VGAPPEND(vgHelgrind_,str)
 
-void* HG_(zalloc) ( HChar* cc, SizeT n );
+void* HG_(zalloc) ( const HChar* cc, SizeT n );
 void  HG_(free)   ( void* p );
-Char* HG_(strdup) ( HChar* cc, const Char* s );
+Char* HG_(strdup) ( const HChar* cc, const Char* s );
 
 static inline Bool HG_(is_sane_ThreadId) ( ThreadId coretid ) {
    return coretid >= 0 && coretid < VG_N_THREADS;
index 5e14a62cb54885dfe54ad1fce64987b8e606a195..45b714e2bf3fb09012da75eae0b7c9641fcf968e 100644 (file)
@@ -148,8 +148,8 @@ typedef
    vec2ix. The entry of the dead WVs in ix2vec are used to maintain a
    linked list of free (to be re-used) ix2vec entries. */
 struct _WordSetU {
-      void*     (*alloc)(HChar*,SizeT);
-      HChar*    cc;
+      void*     (*alloc)(const HChar*,SizeT);
+      const HChar* cc;
       void      (*dealloc)(void*);
       WordFM*   vec2ix; /* WordVec-to-WordSet mapping tree */
       WordVec** ix2vec; /* WordSet-to-WordVec mapping array */
@@ -319,8 +319,8 @@ static WordSet add_or_dealloc_WordVec( WordSetU* wsu, WordVec* wv_new )
       causes failures on a 64-bit platform. */
    tl_assert(wv_new->owner == wsu);
    have = VG_(lookupFM)( wsu->vec2ix, 
-                         (Word*)&wv_old, (Word*)&ix_old,
-                         (Word)wv_new );
+                         (UWord*)&wv_old, (UWord*)&ix_old,
+                         (UWord)wv_new );
    if (have) {
       tl_assert(wv_old != wv_new);
       tl_assert(wv_old);
@@ -336,7 +336,7 @@ static WordSet add_or_dealloc_WordVec( WordSetU* wsu, WordVec* wv_new )
       tl_assert(wsu->ix2vec[ws] == NULL || is_dead(wsu,wsu->ix2vec[ws]));
       wsu->ix2vec_free = (WordVec **) wsu->ix2vec[ws];
       wsu->ix2vec[ws] = wv_new;
-      VG_(addToFM)( wsu->vec2ix, (Word)wv_new, ws );
+      VG_(addToFM)( wsu->vec2ix, (UWord)wv_new, ws );
       if (HG_DEBUG) VG_(printf)("aodW %s re-use free %d %p\n", wsu->cc, (Int)ws, wv_new );
       return ws;
    } else {
@@ -353,8 +353,8 @@ static WordSet add_or_dealloc_WordVec( WordSetU* wsu, WordVec* wv_new )
 }
 
 
-WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( HChar*, SizeT ),
-                             HChar* cc,
+WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( const HChar*, SizeT ),
+                             const HChar* cc,
                              void  (*dealloc)(void*),
                              Word  cacheSize )
 {
@@ -477,8 +477,8 @@ void HG_(dieWS) ( WordSetU* wsu, WordSet ws )
    wsu->ix2vec_free = &wsu->ix2vec[ws];
 
    VG_(delFromFM) ( wsu->vec2ix, 
-                    (Word*)&wv_in_vec2ix, (Word*)&wv_ix,
-                    (Word)wv );
+                    (UWord*)&wv_in_vec2ix, (UWord*)&wv_ix,
+                    (UWord)wv );
 
    if (HG_DEBUG) VG_(printf)("dieWS wv_ix %d\n", (Int)wv_ix);
    tl_assert (wv_ix);
@@ -580,7 +580,7 @@ void HG_(ppWS) ( WordSetU* wsu, WordSet ws )
    VG_(printf)("}");
 }
 
-void HG_(ppWSUstats) ( WordSetU* wsu, HChar* name )
+void HG_(ppWSUstats) ( WordSetU* wsu, const HChar* name )
 {
    VG_(printf)("   WordSet \"%s\":\n", name);
    VG_(printf)("      addTo        %10lu (%lu uncached)\n",
index c918d7c16235c603404f8981167a17b3420ebbba..945836b9b9ae637ea416c279ad09f302bf593393 100644 (file)
@@ -47,8 +47,8 @@ typedef  struct _WordSetU  WordSetU;  /* opaque */
 typedef  UInt              WordSet;   /* opaque, small int index */
 
 /* Allocate and initialise a WordSetU */
-WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( HChar*, SizeT ),
-                             HChar* cc,
+WordSetU* HG_(newWordSetU) ( void* (*alloc_nofail)( const HChar*, SizeT ),
+                             const HChar* cc,
                              void  (*dealloc)(void*),
                              Word  cacheSize );
 
@@ -60,7 +60,7 @@ void HG_(deleteWordSetU) ( WordSetU* );
 UWord HG_(cardinalityWSU) ( WordSetU* );
 
 /* Show performance stats for this WordSetU. */
-void HG_(ppWSUstats) ( WordSetU* wsu, HChar* name );
+void HG_(ppWSUstats) ( WordSetU* wsu, const HChar* name );
 
 
 /* Element-level operations on WordSets.  Note that the WordSet
index 2121665384de8c24d6cae14a1f252f49f2eb1455..76167edaa3d4d8360aa08e03cea858e4fa114399 100644 (file)
 // will abort if they can't allocate the memory).
 // The 'cc' is a string that identifies the allocation point.  It's used when
 // --profile-heap=yes is specified.
-extern void* VG_(malloc)         ( HChar* cc, SizeT nbytes );
+extern void* VG_(malloc)         ( const HChar* cc, SizeT nbytes );
 extern void  VG_(free)           ( void* p );
-extern void* VG_(calloc)         ( HChar* cc, SizeT n, SizeT bytes_per_elem );
-extern void* VG_(realloc)        ( HChar* cc, void* p, SizeT size );
-extern Char* VG_(strdup)         ( HChar* cc, const Char* s );
+extern void* VG_(calloc)         ( const HChar* cc, SizeT n, SizeT bytes_per_elem );
+extern void* VG_(realloc)        ( const HChar* cc, void* p, SizeT size );
+extern Char* VG_(strdup)         ( const HChar* cc, const Char* s );
 
 // Returns the usable size of a heap-block.  It's the asked-for size plus
 // possibly some more due to rounding up.
@@ -58,7 +58,7 @@ extern SizeT VG_(malloc_effective_client_redzone_size)(void);
 // TODO: move somewhere else
 // Call here to bomb the system when out of memory (mmap anon fails)
 __attribute__((noreturn))
-extern void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB );
+extern void VG_(out_of_memory_NORETURN) ( const HChar* who, SizeT szB );
 
 #endif   // __PUB_TOOL_MALLOCFREE_H
 
index 2f8152dc0eb24291230032d20010abffb0abd1ff..9eb789ba7ea51e53c4acd50b5fdbb9a435b60b7d 100644 (file)
@@ -77,7 +77,7 @@ typedef struct _OSet     OSet;
 // - Free:  frees a chunk of memory allocated with Alloc.
 
 typedef Word  (*OSetCmp_t)         ( const void* key, const void* elem );
-typedef void* (*OSetAlloc_t)       ( HChar* cc, SizeT szB );
+typedef void* (*OSetAlloc_t)       ( const HChar* cc, SizeT szB );
 typedef void  (*OSetFree_t)        ( void* p );
 
 /*--------------------------------------------------------------------*/
@@ -99,7 +99,7 @@ typedef void  (*OSetFree_t)        ( void* p );
 //   to allow the destruction of any attached resources;  if NULL it is not
 //   called.
 
-extern OSet* VG_(OSetWord_Create)       ( OSetAlloc_t alloc, HChar* cc, 
+extern OSet* VG_(OSetWord_Create)       ( OSetAlloc_t alloc, const HChar* cc, 
                                           OSetFree_t _free );
 extern void  VG_(OSetWord_Destroy)      ( OSet* os );
 
@@ -197,12 +197,13 @@ extern Bool  VG_(OSetWord_Next)         ( OSet* os, /*OUT*/UWord* val );
 //   lead to assertions in Valgrind's allocator.
 
 extern OSet* VG_(OSetGen_Create)    ( PtrdiffT keyOff, OSetCmp_t cmp,
-                                      OSetAlloc_t alloc, HChar* cc,
+                                      OSetAlloc_t alloc, const HChar* cc,
                                       OSetFree_t _free);
 
 
 extern OSet* VG_(OSetGen_Create_With_Pool)    ( PtrdiffT keyOff, OSetCmp_t cmp,
-                                                OSetAlloc_t alloc, HChar* cc,
+                                                OSetAlloc_t alloc,
+                                                const HChar* cc,
                                                 OSetFree_t _free,
                                                 SizeT poolSize,
                                                 SizeT maxEltSize);
index bc50daa1e436e2c195167f9f2332e61bb4d085f3..e661d9ed4d83f5c6e4462c8c0ef25871520bac20 100644 (file)
@@ -53,8 +53,8 @@ typedef  struct _PoolAlloc  PoolAlloc;
    is, if it returns it must have succeeded.) */
 PoolAlloc* VG_(newPA) ( UWord  elemSzB,
                         UWord  nPerPool,
-                        void*  (*alloc)(HChar*, SizeT),
-                        HChar* cc,
+                        void*  (*alloc)(const HChar*, SizeT),
+                        const  HChar* cc,
                         void   (*free_fn)(void*) );
 
 
index 3c411b9620207e183428876982a78f0a0d00565f..5336fee9c17d71d7ed94bb5ce1649e0427621415 100644 (file)
@@ -49,8 +49,8 @@
 typedef  struct _SparseWA  SparseWA; /* opaque */
 
 // Create a new one, using the specified allocator/deallocator
-SparseWA* VG_(newSWA) ( void*(*alloc_nofail)(HChar* cc, SizeT), 
-                        HChar* cc,
+SparseWA* VG_(newSWA) ( void*(*alloc_nofail)(const HChar* cc, SizeT), 
+                        const HChar* cc,
                         void(*dealloc)(void*) );
 
 // Delete one, and free all associated storage
index ea6c5f3475803368aea29c112e6419bf67b752b4..15bf76a0e614b024e0f4bf1a264b8f174d4d142b 100644 (file)
@@ -76,8 +76,8 @@ typedef  struct _WordFM  WordFM; /* opaque */
    sections of the map, or the whole thing.  If kCmp is NULL then the
    ordering used is unsigned word ordering (UWord) on the key
    values. */
-WordFM* VG_(newFM) ( void* (*alloc_nofail)( HChar* cc, SizeT ),
-                     HChar* cc,
+WordFM* VG_(newFM) ( void* (*alloc_nofail)( const HChar* cc, SizeT ),
+                     const HChar* cc,
                      void  (*dealloc)(void*),
                      Word  (*kCmp)(UWord,UWord) );
 
@@ -174,8 +174,8 @@ SizeT VG_(getNodeSizeFM)( void );
 typedef  struct _WordBag  WordBag; /* opaque */
 
 /* Allocate and initialise a WordBag */
-WordBag* VG_(newBag) ( void* (*alloc_nofail)( HChar* cc, SizeT ),
-                       HChar* cc,
+WordBag* VG_(newBag) ( void* (*alloc_nofail)( const HChar* cc, SizeT ),
+                       const HChar* cc,
                        void  (*dealloc)(void*) );
 
 /* Free up the Bag. */
index 2e1b7d433b27caa7fa9aebc9c41d89c4448734cd..81e05263bcaca24e5009ef927ac1918e31743e6d 100644 (file)
@@ -49,8 +49,8 @@ typedef  struct _XArray  XArray;
 /* Create new XArray, using given allocation and free function, and
    for elements of the specified size.  Alloc fn must not fail (that
    is, if it returns it must have succeeded.) */
-extern XArray* VG_(newXA) ( void*(*alloc_fn)(HChar*,SizeT), 
-                            HChar* cc,
+extern XArray* VG_(newXA) ( void*(*alloc_fn)(const HChar*,SizeT), 
+                            const HChar* cc,
                             void(*free_fn)(void*),
                             Word elemSzB );
 
@@ -129,7 +129,7 @@ extern void VG_(removeIndexXA)( XArray*, Word );
    space (but did return NULL rather than merely abort.)  Space for
    the clone (and all additions to it) is billed to 'cc' unless that
    is NULL, in which case the parent's cost-center is used. */
-extern XArray* VG_(cloneXA)( HChar* cc, XArray* xa );
+extern XArray* VG_(cloneXA)( const HChar* cc, XArray* xa );
 
 /* Get the raw array and size so callers can index it really fast.
    This is dangerous in the sense that there's no range or
index 6252b2a5480b80b40e596510b8b1f966e5015c01..1e3a3767a3aa79c0aeded3e56009cf13044b4e15 100644 (file)
@@ -327,7 +327,7 @@ Int find_chunk_for ( Addr       ptr,
 
 
 static MC_Chunk**
-find_active_chunks(UInt* pn_chunks)
+find_active_chunks(Int* pn_chunks)
 {
    // Our goal is to construct a set of chunks that includes every
    // mempool chunk, and every malloc region that *doesn't* contain a
index 1408a7d1989d284a003dfc90bb0b8fdce9311362..8d3455e2fa95b7da0045dc69253121ef30247847 100644 (file)
@@ -2190,7 +2190,7 @@ static void zeroise_OCacheLine ( OCacheLine* line, Addr tag ) {
 
 static OSet* ocacheL2 = NULL;
 
-static void* ocacheL2_malloc ( HChar* cc, SizeT szB ) {
+static void* ocacheL2_malloc ( const HChar* cc, SizeT szB ) {
    return VG_(malloc)(cc, szB);
 }
 static void ocacheL2_free ( void* v ) {
index 854edf12c1fc0b21c5e64852be2ff4dce3edcb91..57d4a76a34c8e98405b0d1c1cc6731eb4f3521a1 100644 (file)
@@ -54,7 +54,7 @@ static UInt myrandom( void )
   return seed;
 }
 
-static void* allocate_node(HChar* cc, SizeT szB)
+static void* allocate_node(const HChar* cc, SizeT szB)
 { return malloc(szB); }
 
 static void free_node(void* p)
@@ -62,7 +62,7 @@ static void free_node(void* p)
 
 
 //---------------------------------------------------------------------------
-// Word example
+// UWord example
 //---------------------------------------------------------------------------
 
 // This example shows that an element can be a single value (in this
@@ -85,9 +85,9 @@ static Word wordCmp(void* vkey, void* velem)
 void example1singleset(OSet* oset, char *descr)
 {
    Int  i, n;
-   Word v, prev;
-   Word* vs[NN];
-   Word *pv;
+   UWord v, prev;
+   UWord* vs[NN];
+   UWord *pv;
 
    // Try some operations on an empty OSet to ensure they don't screw up.
    vg_assert( ! VG_(OSetGen_Contains)(oset, &v) );
@@ -104,9 +104,9 @@ void example1singleset(OSet* oset, char *descr)
    }
    seed = 0;
    for (i = 0; i < NN; i++) {
-      Word r1  = myrandom() % NN;
-      Word r2  = myrandom() % NN;
-      Word* tmp= vs[r1];
+      UWord r1  = myrandom() % NN;
+      UWord r2  = myrandom() % NN;
+      UWord* tmp= vs[r1];
       vs[r1]   = vs[r2];
       vs[r2]   = tmp;
    }
@@ -229,7 +229,7 @@ void example1(void)
                                         NULL,
                                         allocate_node, "oset_test.1",
                                         free_node,
-                                        101, sizeof(Word));
+                                        101, sizeof(UWord));
    example1singleset(oset, "single oset, pool allocator");
 
    // Destroy the OSet
@@ -241,7 +241,7 @@ void example1(void)
       (0,
        NULL,
        allocate_node, "oset_test.1", free_node,
-       101, sizeof(Word));
+       101, sizeof(UWord));
    oset_empty_clone = VG_(OSetGen_EmptyClone) (oset);
    example1singleset(oset, "oset, shared pool");
    example1singleset(oset_empty_clone, "cloned oset, shared pool");
@@ -255,8 +255,8 @@ void example1(void)
 void example1b(void)
 {
    Int  i, n;
-   Word v = 0, prev;
-   Word vs[NN];
+   UWord v = 0, prev;
+   UWord vs[NN];
 
    // Create a static OSet of Ints.  This one uses fast (built-in)
    // comparisons.
@@ -275,9 +275,9 @@ void example1b(void)
    }
    seed = 0;
    for (i = 0; i < NN; i++) {
-      Word r1  = myrandom() % NN;
-      Word r2  = myrandom() % NN;
-      Word tmp = vs[r1];
+      UWord r1  = myrandom() % NN;
+      UWord r2  = myrandom() % NN;
+      UWord tmp = vs[r1];
       vs[r1]   = vs[r2];
       vs[r2]   = tmp;
    }
@@ -317,7 +317,7 @@ void example1b(void)
    prev = -1;
    VG_(OSetWord_ResetIter)(oset);
    while ( VG_(OSetWord_Next)(oset, &v) ) {
-      Word curr = v;
+      UWord curr = v;
       assert(prev < curr); 
       prev = curr;
       n++;