aboutsummaryrefslogtreecommitdiff
path: root/src/common/mac
diff options
context:
space:
mode:
authormmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-08-20 19:29:41 +0000
committermmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-08-20 19:29:41 +0000
commitebe77d7e3bdd6c39522fceab23a87b4e1b697b77 (patch)
tree042bd6d0ad43a5d0dfcc0c3ec2efe0ddcbf5674f /src/common/mac
parentMerge of Breakpad Chrome Linux fork (diff)
downloadbreakpad-ebe77d7e3bdd6c39522fceab23a87b4e1b697b77.tar.xz
Provide a real std::string hash, not just a forward declaration for something
that doesn't exist. TBR=nealsid Code review URL: http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/292f9ed79dfdbdde git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@391 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/mac')
-rw-r--r--src/common/mac/dwarf/functioninfo.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/common/mac/dwarf/functioninfo.cc b/src/common/mac/dwarf/functioninfo.cc
index b6d3f0fe..267d6cf9 100644
--- a/src/common/mac/dwarf/functioninfo.cc
+++ b/src/common/mac/dwarf/functioninfo.cc
@@ -39,14 +39,25 @@
#include "common/mac/dwarf/bytereader.h"
-namespace __gnu_cxx
-{
- template<>
- struct hash<std::string>
- {
- size_t operator()(const std::string& k) const;
- };
-}
+namespace __gnu_cxx {
+
+// Implement a string hash function so that std::string can be used as a key
+// in STL maps and sets. The hash algorithm comes from the GNU C++ library,
+// in <tr1/functional>. It is duplicated here because GCC versions prior to
+// 4.3.2 are unable to compile <tr1/functional> when RTTI is disabled, as it
+// may be in this code.
+
+template<>
+struct hash<std::string> {
+ std::size_t operator()(const std::string& s) const {
+ std::size_t result = 0;
+ for (std::string::const_iterator i = s.begin(); i != s.end(); ++i)
+ result = (result * 131) + *i;
+ return result;
+ }
+};
+
+} // namespace __gnu_cxx
namespace dwarf2reader {