]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add const qualifiers to appropriate arguments of OSet routines.
authorTom Hughes <tom@compton.nu>
Sun, 30 Dec 2007 12:28:26 +0000 (12:28 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 30 Dec 2007 12:28:26 +0000 (12:28 +0000)
Patch from Bart Van Assche <bart.vanassche@gmail.com>.

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

cachegrind/cg_main.c
coregrind/m_oset.c
include/pub_tool_oset.h

index 9fae9de57324044ca15e72e8b3196955928f6b2b..45dfd701467250727409131a8f6332a1a862cf0c 100644 (file)
@@ -112,7 +112,7 @@ typedef struct {
 } LineCC;
 
 // First compare file, then fn, then line.
-static Word cmp_CodeLoc_LineCC(void *vloc, void *vcc)
+static Word cmp_CodeLoc_LineCC(const void *vloc, const void *vcc)
 {
    Word res;
    CodeLoc* a = (CodeLoc*)vloc;
@@ -182,7 +182,7 @@ static Int  no_debugs           = 0;
 /*--- String table operations                              ---*/
 /*------------------------------------------------------------*/
 
-static Word stringCmp( void* key, void* elem )
+static Word stringCmp( const void* key, const void* elem )
 {
    return VG_(strcmp)(*(Char**)key, *(Char**)elem);
 }
index ad3b66dde220016319e692e50e604821f321e09c..5b6843dcdc172bc32197f46f7485cd3c27f47edf 100644 (file)
@@ -189,7 +189,7 @@ static inline Word fast_cmp(void* k, AvlNode* n)
 }
 
 // Compare a key and an element.  Inlining is *crucial*.
-static inline Word slow_cmp(AvlTree* t, void* k, AvlNode* n)
+static inline Word slow_cmp(const AvlTree* t, const void* k, const AvlNode* n)
 {
    return t->cmp(k, elem_of_node(n));
 }
@@ -490,7 +490,7 @@ void VG_(OSetWord_Insert)(AvlTree* t, Word val)
 /*--------------------------------------------------------------------*/
 
 // Find the *node* in t matching k, or NULL if not found.
-static AvlNode* avl_lookup(AvlTree* t, void* k)
+static AvlNode* avl_lookup(const AvlTree* t, const void* k)
 {
    Word     cmpres;
    AvlNode* curr = t->root;
@@ -522,7 +522,7 @@ static AvlNode* avl_lookup(AvlTree* t, void* k)
 }
 
 // Find the *element* in t matching k, or NULL if not found.
-void* VG_(OSetGen_Lookup)(AvlTree* t, void* k)
+void* VG_(OSetGen_Lookup)(const AvlTree* t, const void* k)
 {
    AvlNode* n;
    vg_assert(t);
@@ -532,7 +532,7 @@ void* VG_(OSetGen_Lookup)(AvlTree* t, void* k)
 
 // Find the *element* in t matching k, or NULL if not found;  use the given
 // comparison function rather than the standard one.
-void* VG_(OSetGen_LookupWithCmp)(AvlTree* t, void* k, OSetCmp_t cmp)
+void* VG_(OSetGen_LookupWithCmp)(AvlTree* t, const void* k, OSetCmp_t cmp)
 {
    // Save the normal one to the side, then restore once we're done.
    void* e;
@@ -546,7 +546,7 @@ void* VG_(OSetGen_LookupWithCmp)(AvlTree* t, void* k, OSetCmp_t cmp)
 }
 
 // Is there an element matching k?
-Bool VG_(OSetGen_Contains)(AvlTree* t, void* k)
+Bool VG_(OSetGen_Contains)(const AvlTree* t, const void* k)
 {
    return (NULL != VG_(OSetGen_Lookup)(t, k));
 }
@@ -775,7 +775,7 @@ Bool VG_(OSetWord_Next)(AvlTree* t, Word* val)
 /*--- Miscellaneous operations                                     ---*/
 /*--------------------------------------------------------------------*/
 
-Int VG_(OSetGen_Size)(AvlTree* t)
+Int VG_(OSetGen_Size)(const AvlTree* t)
 {
    vg_assert(t);
    return t->nElems;
index eafdc9a5641c594cdd7e822fe8fd6caeb28b06aa..e96274047a523b3363125ab5ffa55405d5202725 100644 (file)
@@ -76,7 +76,7 @@ typedef struct _OSet     OSet;
 // - Alloc: allocates a chunk of memory.
 // - Free: frees a chunk of memory allocated with Alloc.
 
-typedef Word  (*OSetCmp_t)         ( void* key, void* elem );
+typedef Word  (*OSetCmp_t)         ( const void* key, const void* elem );
 typedef void* (*OSetAlloc_t)       ( SizeT szB );
 typedef void  (*OSetFree_t)        ( void* p );
 
@@ -234,11 +234,11 @@ extern void  VG_(OSetGen_FreeNode)  ( OSet* os, void* elem );
 //   they will return NULL if VG_(OSetGen_Next)() is called without an
 //   intervening call to VG_(OSetGen_ResetIter)().
 
-extern Int   VG_(OSetGen_Size)         ( OSet* os );
+extern Int   VG_(OSetGen_Size)         ( const OSet* os );
 extern void  VG_(OSetGen_Insert)       ( OSet* os, void* elem );
-extern Bool  VG_(OSetGen_Contains)     ( OSet* os, void* key  );
-extern void* VG_(OSetGen_Lookup)       ( OSet* os, void* key  );
-extern void* VG_(OSetGen_LookupWithCmp)( OSet* os, void* key, OSetCmp_t cmp );
+extern Bool  VG_(OSetGen_Contains)     ( const OSet* os, const void* key  );
+extern void* VG_(OSetGen_Lookup)       ( const OSet* os, const void* key  );
+extern void* VG_(OSetGen_LookupWithCmp)( OSet* os, const void* key, OSetCmp_t cmp );
 extern void* VG_(OSetGen_Remove)       ( OSet* os, void* key  );
 extern void  VG_(OSetGen_ResetIter)    ( OSet* os );
 extern void* VG_(OSetGen_Next)         ( OSet* os );