diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-18 06:33:03 +1000 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-18 06:33:03 +1000 |
commit | 33c029dd77888ee5f9b1c7ce8884c982e0428adf (patch) | |
tree | 6c38a3f4c4dcc2fb20a8ce4a1c9d1dc520ec6f9d /rts/Hash.c | |
parent | 5d80d14196ef048ffe037b2d92af2e9af0cb9e19 (diff) | |
download | haskell-33c029dd77888ee5f9b1c7ce8884c982e0428adf.tar.gz |
rts: More const correct-ness fixes
In addition to more const-correctness fixes this patch fixes an
infelicity of the previous const-correctness patch (995cf0f356) which
left `UNTAG_CLOSURE` taking a `const StgClosure` pointer parameter
but returning a non-const pointer. Here we restore the original type
signature of `UNTAG_CLOSURE` and add a new function
`UNTAG_CONST_CLOSURE` which takes and returns a const `StgClosure`
pointer and uses that wherever possible.
Test Plan: Validate on Linux, OS X and Windows
Reviewers: Phyx, hsyl20, bgamari, austin, simonmar, trofi
Reviewed By: simonmar, trofi
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2231
Diffstat (limited to 'rts/Hash.c')
-rw-r--r-- | rts/Hash.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rts/Hash.c b/rts/Hash.c index b0939c49bc..1b193e3247 100644 --- a/rts/Hash.c +++ b/rts/Hash.c @@ -29,7 +29,7 @@ /* Linked list of (key, data) pairs for separate chaining */ typedef struct hashlist { StgWord key; - void *data; + const void *data; struct hashlist *next; /* Next cell in bucket chain (same hash value) */ } HashList; @@ -200,7 +200,7 @@ lookupHashTable(const HashTable *table, StgWord key) for (hl = table->dir[segment][index]; hl != NULL; hl = hl->next) if (table->compare(hl->key, key)) - return hl->data; + return (void *) hl->data; /* It's not there */ return NULL; @@ -274,7 +274,7 @@ freeHashList (HashTable *table, HashList *hl) } void -insertHashTable(HashTable *table, StgWord key, void *data) +insertHashTable(HashTable *table, StgWord key, const void *data) { int bucket; int segment; @@ -323,7 +323,7 @@ removeHashTable(HashTable *table, StgWord key, void *data) prev->next = hl->next; freeHashList(table,hl); table->kcount--; - return hl->data; + return (void *) hl->data; } prev = hl; } @@ -357,7 +357,7 @@ freeHashTable(HashTable *table, void (*freeDataFun)(void *) ) for (hl = table->dir[segment][index]; hl != NULL; hl = next) { next = hl->next; if (freeDataFun != NULL) - (*freeDataFun)(hl->data); + (*freeDataFun)((void *) hl->data); } index--; } |