problem while searching value in dense_hash_map
Closed this issue · 2 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1.i have create by google::dense_hash_map<char*, char*> dmap; golbally
2.call insert keys &values by using dmap[key]=value;
3.use dmap.find(key)in another function but getting garbage value
What is the expected output? What do you see instead?
want the value of correspoing key
What version of the product are you using? On what operating system?
on linunx redhat
Please provide any additional information below.
attached code below
Original issue reported on code.google.com by praj.cha...@gmail.com
on 28 Jun 2012 at 1:14
Attachments:
GoogleCodeExporter commented
You need to manage the string storage on your own; dense_hash_map doesn't do
that for you. (Nor does STL hash_map or similar.) For example, this code has a
"dangling pointer" bug:
hash_map<char*, char*> m;
{
char tmp[10];
tmp[0] = 'a';
tmp[1] = '\0';
m[tmp] = tmp;
}
puts(m["a"]);
By the way, tools such as valgrind and purify can find most bugs like these.
Original comment by gp...@google.com
on 28 Jun 2012 at 3:44
- Changed state: Invalid
GoogleCodeExporter commented
Hi,
But Keys & values are inserted properly into the map but problem is
their in retrieving it
Original comment by praj.cha...@gmail.com
on 29 Jun 2012 at 4:35