Skip to content

Commit

Permalink
allow pointers as keys in maps, treating them the same as ints - ptr …
Browse files Browse the repository at this point in the history
…eq not value equality

R=ken,gri
OCL=13879
CL=13879
  • Loading branch information
robpike committed Aug 5, 2008
1 parent 033682d commit 5adbacb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/runtime/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sys·newmap(uint32 keysize, uint32 valsize,
{
Hmap *m;

if(keyalg >= 2 ||
if(keyalg >= 3 ||
valalg >= 3) {
prints("0<=");
sys·printint(keyalg);
Expand Down
7 changes: 4 additions & 3 deletions src/runtime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ pointercopy(uint32 s, void **a, void **b)
Alg
algarray[3] =
{
{ &memhash, &memequal, &memprint, &memcopy },
{ &stringhash, &stringequal, &stringprint, &stringcopy },
{ &pointerhash, &pointerequal, &pointerprint, &pointercopy },
{ &memhash, &memequal, &memprint, &memcopy }, // 0
{ &stringhash, &stringequal, &stringprint, &stringcopy }, // 1
// { &pointerhash, &pointerequal, &pointerprint, &pointercopy }, // 2
{ &memhash, &memequal, &memprint, &memcopy }, // 2 - treat pointers as ints
};

0 comments on commit 5adbacb

Please sign in to comment.