]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change the definition of VgHashTable to not have pointer type.
authorFlorian Krohm <florian@eich-krohm.de>
Sat, 18 Oct 2014 10:58:05 +0000 (10:58 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sat, 18 Oct 2014 10:58:05 +0000 (10:58 +0000)
This is (a) consistent with how the other containers are defined
and, more importantly, (b) allows the constification of the hash table API.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14639

coregrind/m_debuginfo/readdwarf3.c
coregrind/m_deduppoolalloc.c
coregrind/m_gdbserver/m_gdbserver.c
coregrind/m_hashtable.c
drd/drd_malloc_wrappers.c
helgrind/hg_main.c
include/pub_tool_hashtable.h
massif/ms_main.c
memcheck/mc_include.h
memcheck/mc_malloc_wrappers.c

index db924d72f36872c5ca31b1f15e946bbf56ec30c0..89c7e2fff09b394a01adc9157e11de90213ce130 100644 (file)
@@ -467,7 +467,7 @@ typedef
       /* --- Needed so we can add stuff to the string table. --- */
       struct _DebugInfo* di;
       /* --- a hash table of g_abbv (i.e. parsed abbreviations) --- */
-      VgHashTable ht_abbvs;
+      VgHashTable *ht_abbvs;
 
       /* True if this came from .debug_types; otherwise it came from
          .debug_info.  */
@@ -480,7 +480,7 @@ typedef
 
       /* Signatured type hash; computed once and then shared by all
          CUs.  */
-      VgHashTable signature_types;
+      VgHashTable *signature_types;
 
       /* True if this came from alternate .debug_info; otherwise
          it came from normal .debug_info or .debug_types.  */
@@ -1081,7 +1081,7 @@ typedef
    D3SignatureType;
 
 /* Record a signatured type in the hash table.  */
-static void record_signatured_type ( VgHashTable tab,
+static void record_signatured_type ( VgHashTable *tab,
                                      ULong type_signature,
                                      UWord die )
 {
@@ -1096,7 +1096,7 @@ static void record_signatured_type ( VgHashTable tab,
 /* Given a type signature hash table and a type signature, return the
    cooked DIE offset of the type.  If the type cannot be found, call
    BARF.  */
-static UWord lookup_signatured_type ( VgHashTable tab,
+static UWord lookup_signatured_type ( const VgHashTable *tab,
                                       ULong type_signature,
                                       void (*barf)( const HChar* ) __attribute__((noreturn)) )
 {
@@ -4439,7 +4439,7 @@ void new_dwarf3_reader_wrk (
    Bool td3 = di->trace_symtab;
    XArray* /* of TempVar* */ dioff_lookup_tab;
    Int pass;
-   VgHashTable signature_types = NULL;
+   VgHashTable *signature_types = NULL;
 
    /* Display/trace various information, if requested. */
    if (TD3) {
index 53d68535e74fae6b5437449ddbee74a277afa49e..dd69c7ffd5d535f2f97c65e7adedc95b13bba1f9 100644 (file)
@@ -52,7 +52,7 @@ struct _DedupPoolAlloc {
 
    /* hash table of pool elements, used to dedup.
       If NULL, it means the DedupPoolAlloc is frozen. */
-   VgHashTable ht_elements;
+   VgHashTable *ht_elements;
 
    /* Hash table nodes of pool_elements are allocated with a pool, to
       decrease memory overhead during insertion in the DedupPoolAlloc. */
index 3ce18606aaa011e77d6ea86c97a1eee5dcd551ff..6e10593fbfd947478d0dbb2fddcb4883e8e2a09b 100644 (file)
@@ -194,7 +194,7 @@ typedef
 
    Note for ARM: addr in GS_Address is the value without the thumb bit set.
 */
-static VgHashTable gs_addresses = NULL;
+static VgHashTable *gs_addresses = NULL;
 
 // Transform addr in the form stored in the list of addresses.
 // For the ARM architecture, we store it with the thumb bit set to 0.
index 5abea0a57284b8f402bfc42ec34a1f2b1e03ef16..3e52235862a4390096b4cd7dac925bd99235a160 100644 (file)
@@ -54,7 +54,7 @@ struct _VgHashTable {
 
 #define N_HASH_PRIMES 20
 
-static SizeT primes[N_HASH_PRIMES] = {
+static const SizeT primes[N_HASH_PRIMES] = {
          769UL,         1543UL,         3079UL,          6151UL,
        12289UL,        24593UL,        49157UL,         98317UL,
       196613UL,       393241UL,       786433UL,       1572869UL,
@@ -66,12 +66,12 @@ static SizeT primes[N_HASH_PRIMES] = {
 /*--- Functions                                                    ---*/
 /*--------------------------------------------------------------------*/
 
-VgHashTable VG_(HT_construct) ( const HChar* name )
+VgHashTable *VG_(HT_construct) ( const HChar* name )
 {
    /* Initialises to zero, ie. all entries NULL */
    SizeT       n_chains = primes[0];
    SizeT       sz       = n_chains * sizeof(VgHashNode*);
-   VgHashTable table    = VG_(calloc)("hashtable.Hc.1",
+   VgHashTable *table   = VG_(calloc)("hashtable.Hc.1",
                                       1, sizeof(struct _VgHashTable));
    table->chains        = VG_(calloc)("hashtable.Hc.2", 1, sz);
    table->n_chains      = n_chains;
@@ -82,12 +82,12 @@ VgHashTable VG_(HT_construct) ( const HChar* name )
    return table;
 }
 
-Int VG_(HT_count_nodes) ( VgHashTable table )
+Int VG_(HT_count_nodes) ( const VgHashTable *table )
 {
    return table->n_elements;
 }
 
-static void resize ( VgHashTable table )
+static void resize ( VgHashTable *table )
 {
    Int          i;
    SizeT        sz;
@@ -141,7 +141,7 @@ static void resize ( VgHashTable table )
 
 /* Puts a new, heap allocated VgHashNode, into the VgHashTable.  Prepends
    the node to the appropriate chain.  No duplicate key detection is done. */
-void VG_(HT_add_node) ( VgHashTable table, void* vnode )
+void VG_(HT_add_node) ( VgHashTable *table, void* vnode )
 {
    VgHashNode* node     = (VgHashNode*)vnode;
    UWord chain          = CHAIN_NO(node->key, table);
@@ -157,7 +157,7 @@ void VG_(HT_add_node) ( VgHashTable table, void* vnode )
 }
 
 /* Looks up a VgHashNode by key in the table.  Returns NULL if not found. */
-void* VG_(HT_lookup) ( VgHashTable table, UWord key )
+void* VG_(HT_lookup) ( const VgHashTable *table, UWord key )
 {
    VgHashNode* curr = table->chains[ CHAIN_NO(key, table) ];
 
@@ -172,9 +172,10 @@ void* VG_(HT_lookup) ( VgHashTable table, UWord key )
 
 /* Looks up a VgHashNode by node in the table.  Returns NULL if not found.
    GEN!!! marks the lines that differs from VG_(HT_lookup). */
-void* VG_(HT_gen_lookup) ( VgHashTable table, void* node, HT_Cmp_t cmp )
+void* VG_(HT_gen_lookup) ( const VgHashTable *table, const void* node,
+                           HT_Cmp_t cmp )
 {
-   VgHashNode* hnode = (VgHashNode*) node; // GEN!!!
+   const VgHashNode* hnode = node; // GEN!!!
    VgHashNode* curr = table->chains[ CHAIN_NO(hnode->key, table) ]; // GEN!!!
 
    while (curr) {
@@ -187,7 +188,7 @@ void* VG_(HT_gen_lookup) ( VgHashTable table, void* node, HT_Cmp_t cmp )
 }
 
 /* Removes a VgHashNode from the table.  Returns NULL if not found. */
-void* VG_(HT_remove) ( VgHashTable table, UWord key )
+void* VG_(HT_remove) ( VgHashTable *table, UWord key )
 {
    UWord        chain         = CHAIN_NO(key, table);
    VgHashNode*  curr          =   table->chains[chain];
@@ -210,9 +211,9 @@ void* VG_(HT_remove) ( VgHashTable table, UWord key )
 
 /* Removes a VgHashNode by node from the table.  Returns NULL if not found.
    GEN!!! marks the lines that differs from VG_(HT_remove). */
-void* VG_(HT_gen_remove) ( VgHashTable table, void* node, HT_Cmp_t cmp  )
+void* VG_(HT_gen_remove) ( VgHashTable *table, const void* node, HT_Cmp_t cmp  )
 {
-   VgHashNode* hnode = (VgHashNode*) node; // GEN!!!
+   const VgHashNode* hnode    = node; // GEN!!!
    UWord        chain         = CHAIN_NO(hnode->key, table); // GEN!!!
    VgHashNode*  curr          =   table->chains[chain];
    VgHashNode** prev_next_ptr = &(table->chains[chain]);
@@ -232,7 +233,7 @@ void* VG_(HT_gen_remove) ( VgHashTable table, void* node, HT_Cmp_t cmp  )
    return NULL;
 }
 
-void VG_(HT_print_stats) ( VgHashTable table, HT_Cmp_t cmp )
+void VG_(HT_print_stats) ( const VgHashTable *table, HT_Cmp_t cmp )
 {
    #define MAXOCCUR 20
    UInt elt_occurences[MAXOCCUR+1];
@@ -328,7 +329,7 @@ void VG_(HT_print_stats) ( VgHashTable table, HT_Cmp_t cmp )
    elements into it, then returns both the array and the size of it.  The
    array must be freed with VG_(free).
 */
-VgHashNode** VG_(HT_to_array) ( VgHashTable table, /*OUT*/ UInt* n_elems )
+VgHashNode** VG_(HT_to_array) (const VgHashTable *table, /*OUT*/ UInt* n_elems)
 {
    UInt       i, j;
    VgHashNode** arr;
@@ -351,7 +352,7 @@ VgHashNode** VG_(HT_to_array) ( VgHashTable table, /*OUT*/ UInt* n_elems )
    return arr;
 }
 
-void VG_(HT_ResetIter)(VgHashTable table)
+void VG_(HT_ResetIter)(VgHashTable *table)
 {
    vg_assert(table);
    table->iterNode  = NULL;
@@ -359,7 +360,7 @@ void VG_(HT_ResetIter)(VgHashTable table)
    table->iterOK    = True;
 }
 
-void* VG_(HT_Next)(VgHashTable table)
+void* VG_(HT_Next)(VgHashTable *table)
 {
    Int i;
    vg_assert(table);
@@ -383,7 +384,7 @@ void* VG_(HT_Next)(VgHashTable table)
    return NULL;
 }
 
-void VG_(HT_destruct)(VgHashTable table, void(*freenode_fn)(void*))
+void VG_(HT_destruct)(VgHashTable *table, void(*freenode_fn)(void*))
 {
    UInt       i;
    VgHashNode *node, *node_next;
index 0f9896467e2ee4d74800408bdca6a5350d2754be..369936de58afb07998f08842adf6b0e438db64ed 100644 (file)
@@ -61,7 +61,7 @@ static SizeT s_cmalloc_n_mallocs  = 0;
 static SizeT s_cmalloc_n_frees    = 0;
 static SizeT s_cmalloc_bs_mallocd = 0;
 /* Record malloc'd blocks. */
-static VgHashTable s_malloc_list = NULL;
+static VgHashTable *s_malloc_list = NULL;
 
 
 /* Function definitions. */
index d1b72d0d0e42bf3073b82542666ecad873664bfe..3f130743cc6930b823f50387cfe16cb1706fce96 100644 (file)
@@ -3974,7 +3974,7 @@ typedef
 
 /* A hash table of MallocMetas, used to track malloc'd blocks
    (obviously). */
-static VgHashTable hg_mallocmeta_table = NULL;
+static VgHashTable *hg_mallocmeta_table = NULL;
 
 /* MallocMeta are small elements. We use a pool to avoid
    the overhead of malloc for each MallocMeta. */
index 21dd0b234a13643d07ed8a8f20c1d97bbbf3977c..b105ac40435691b0ab98fbd909683fada616a4ea 100644 (file)
@@ -49,28 +49,28 @@ typedef
    }
    VgHashNode;
 
-typedef struct _VgHashTable VgHashTable;
+typedef struct _VgHashTable VgHashTable;
 
 /* Make a new table.  Allocates the memory with VG_(calloc)(), so can
    be freed with VG_(free)().  The table starts small but will
    periodically be expanded.  This is transparent to the users of this
    module. The function never returns NULL. */
-extern VgHashTable VG_(HT_construct) ( const HChar* name );
+extern VgHashTable *VG_(HT_construct) ( const HChar* name );
 
 /* Count the number of nodes in a table. */
-extern Int VG_(HT_count_nodes) ( VgHashTable table );
+extern Int VG_(HT_count_nodes) ( const VgHashTable *table );
 
 /* Add a node to the table.  Duplicate keys are permitted. */
-extern void VG_(HT_add_node) ( VgHashTable t, void* node );
+extern void VG_(HT_add_node) ( VgHashTable *t, void* node );
 
 /* Looks up a VgHashNode by key in the table.  
  * Returns NULL if not found.  If entries
  * with duplicate keys are present, the most recently-added of the dups will
  * be returned, but it's probably better to avoid dups altogether. */
-extern void* VG_(HT_lookup) ( VgHashTable table, UWord key );
+extern void* VG_(HT_lookup) ( const VgHashTable *table, UWord key );
 
 /* Removes a VgHashNode by key from the table.  Returns NULL if not found. */
-extern void* VG_(HT_remove) ( VgHashTable table, UWord key );
+extern void* VG_(HT_remove) ( VgHashTable *table, UWord key );
 
 typedef Word  (*HT_Cmp_t) ( const void* node1, const void* node2 );
 
@@ -85,22 +85,25 @@ typedef Word  (*HT_Cmp_t) ( const void* node1, const void* node2 );
       between components, either the node memory should be fully initialised
       (e.g. allocated using VG_(calloc)) or each component should be compared
        individually. */
-extern void* VG_(HT_gen_lookup) ( VgHashTable table, void* node, HT_Cmp_t cmp );
-extern void* VG_(HT_gen_remove) ( VgHashTable table, void* node, HT_Cmp_t cmp );
+extern void* VG_(HT_gen_lookup) ( const VgHashTable *table, const void* node,
+                                  HT_Cmp_t cmp );
+extern void* VG_(HT_gen_remove) ( VgHashTable *table, const void* node,
+                                  HT_Cmp_t cmp );
 
 /* Output detailed usage/collision statistics.
    cmp will be used to verify if 2 elements with the same key are equal.
    Use NULL cmp if the hash table elements are only to be compared by key. */
-extern void VG_(HT_print_stats) ( VgHashTable table, HT_Cmp_t cmp );
+extern void VG_(HT_print_stats) ( const VgHashTable *table, HT_Cmp_t cmp );
 
 /* Allocates a suitably-sized array, copies pointers to all the hashtable
    elements into it, then returns both the array and the size of it.  The
    array must be freed with VG_(free). If the hashtable is empty, the
    function returns NULL and assigns *nelems = 0. */
-extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_elems );
+extern VgHashNode** VG_(HT_to_array) ( const VgHashTable *table,
+                                       /*OUT*/ UInt* n_elems );
 
 /* Reset the table's iterator to point to the first element. */
-extern void VG_(HT_ResetIter) ( VgHashTable table );
+extern void VG_(HT_ResetIter) ( VgHashTable *table );
 
 /* Return the element pointed to by the iterator and move on to the
    next one.  Returns NULL if the last one has been passed, or if
@@ -113,11 +116,11 @@ extern void VG_(HT_ResetIter) ( VgHashTable table );
    Since resizing only happens as a result of calling HT_add_node,
    disallowing HT_add_node during iteration should give the required
    assurance. */
-extern void* VG_(HT_Next) ( VgHashTable table );
+extern void* VG_(HT_Next) ( VgHashTable *table );
 
 /* Destroy a table and deallocates the memory used by the nodes using
    freenode_fn.*/
-extern void VG_(HT_destruct) ( VgHashTable t, void(*freenode_fn)(void*) );
+extern void VG_(HT_destruct) ( VgHashTable *table, void(*freenode_fn)(void*) );
 
 
 #endif   // __PUB_TOOL_HASHTABLE_H
index 7d78b5f092087f13d606b50d830e0f8408177422..da58bb665c341b30631f7bcea602465f240286ac 100644 (file)
@@ -1485,7 +1485,7 @@ typedef
    }
    HP_Chunk;
 
-static VgHashTable malloc_list  = NULL;   // HP_Chunks
+static VgHashTable *malloc_list  = NULL;   // HP_Chunks
 
 static void update_alloc_stats(SSizeT szB_delta)
 {
index 26ad25e1fdf6fe2e1c26939e976e407f24040ed0..51a36c2dc739d01e7298fb7f0fc415aac9dcc32b 100644 (file)
@@ -93,7 +93,7 @@ typedef
       Addr          pool;           // pool identifier
       SizeT         rzB;            // pool red-zone size
       Bool          is_zeroed;      // allocations from this pool are zeroed
-      VgHashTable   chunks;         // chunks associated with this pool
+      VgHashTable  *chunks;         // chunks associated with this pool
    }
    MC_Mempool;
 
@@ -101,7 +101,7 @@ typedef
 void* MC_(new_block)  ( ThreadId tid,
                         Addr p, SizeT size, SizeT align,
                         Bool is_zeroed, MC_AllocKind kind,
-                        VgHashTable table);
+                        VgHashTable *table);
 void MC_(handle_free) ( ThreadId tid,
                         Addr p, UInt rzB, MC_AllocKind kind );
 
@@ -127,10 +127,10 @@ extern PoolAlloc* MC_(chunk_poolalloc);
    VgHashTable, because VgHashTable allows duplicate keys without complaint.
    This can occur if a user marks a malloc() block as also a custom block with
    MALLOCLIKE_BLOCK. */
-extern VgHashTable MC_(malloc_list);
+extern VgHashTable *MC_(malloc_list);
 
 /* For tracking memory pools. */
-extern VgHashTable MC_(mempool_list);
+extern VgHashTable *MC_(mempool_list);
 
 /* Shadow memory functions */
 Bool MC_(check_mem_is_noaccess)( Addr a, SizeT len, Addr* bad_addr );
index d88890ba7b7f6074fdf0e57730531274c04eaba8..630c9c7e15cedb382843afdef3e4cc332c8bc43e 100644 (file)
@@ -66,11 +66,11 @@ static ULong cmalloc_bs_mallocd = 0;
 SizeT MC_(Malloc_Redzone_SzB) = -10000000; // If used before set, should BOMB
 
 /* Record malloc'd blocks. */
-VgHashTable MC_(malloc_list) = NULL;
+VgHashTable *MC_(malloc_list) = NULL;
 
 /* Memory pools: a hash table of MC_Mempools.  Search key is
    MC_Mempool::pool. */
-VgHashTable MC_(mempool_list) = NULL;
+VgHashTable *MC_(mempool_list) = NULL;
 
 /* Pool allocator for MC_Chunk. */   
 PoolAlloc *MC_(chunk_poolalloc) = NULL;
@@ -224,7 +224,7 @@ void delete_MC_Chunk (MC_Chunk* mc)
 }
 
 // True if mc is in the given block list.
-static Bool in_block_list (VgHashTable block_list, MC_Chunk* mc)
+static Bool in_block_list (const VgHashTable *block_list, MC_Chunk* mc)
 {
    MC_Chunk* found_mc = VG_(HT_lookup) ( block_list, (UWord)mc->data );
    if (found_mc) {
@@ -338,7 +338,7 @@ UInt MC_(n_where_pointers) (void)
 /* Allocate memory and note change in memory available */
 void* MC_(new_block) ( ThreadId tid,
                        Addr p, SizeT szB, SizeT alignB,
-                       Bool is_zeroed, MC_AllocKind kind, VgHashTable table)
+                       Bool is_zeroed, MC_AllocKind kind, VgHashTable *table)
 {
    MC_Chunk* mc;