From: Tom Hughes Date: Sun, 30 Dec 2007 12:28:26 +0000 (+0000) Subject: Add const qualifiers to appropriate arguments of OSet routines. X-Git-Tag: svn/VALGRIND_3_4_0~1120 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f4849d83f25a456eee7b59a8dbb72bc7f72b3a8;p=thirdparty%2Fvalgrind.git Add const qualifiers to appropriate arguments of OSet routines. Patch from Bart Van Assche . git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7308 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 9fae9de573..45dfd70146 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -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); } diff --git a/coregrind/m_oset.c b/coregrind/m_oset.c index ad3b66dde2..5b6843dcdc 100644 --- a/coregrind/m_oset.c +++ b/coregrind/m_oset.c @@ -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; diff --git a/include/pub_tool_oset.h b/include/pub_tool_oset.h index eafdc9a564..e96274047a 100644 --- a/include/pub_tool_oset.h +++ b/include/pub_tool_oset.h @@ -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 );