Apply patch from Daniel Schürmann: https://sourceforge.net/p/boomerang/bugs/78/
[boomerang.git] / boomerang / loader / SymTab.cpp
blob72322ca47902479a87af30abf8f9887b0c4de1c6
1 /*
2 * Copyright (C) 2005, Mike Van Emmerik
4 * See the file "LICENSE.TERMS" for information on usage and
5 * redistribution of this file, and for a DISCLAIMER OF ALL
6 * WARRANTIES.
8 */
10 /*==============================================================================
11 * FILE: SymTab.cpp
12 * OVERVIEW: This file contains the implementation of the class SymTab, a simple class to maintain a pair of maps
13 * so that symbols can be accessed by symbol or by name
14 *============================================================================*/
16 * $Revision$
18 * 12 Jul 05 - Mike: threw out the bsearch() code and implemented dual maps instead
21 #include "SymTab.h"
23 SymTab::SymTab()
26 SymTab::~SymTab()
29 void SymTab::Add(ADDRESS a, char* s)
31 amap[a] = s;
32 smap[s] = a;
35 const char* SymTab::find(ADDRESS a)
37 std::map<ADDRESS, std::string>::iterator ff;
38 ff = amap.find(a);
39 if (ff == amap.end())
40 return NULL;
41 return ff->second.c_str();
44 ADDRESS SymTab::find(const char* s)
46 std::map<std::string, ADDRESS>::iterator ff;
47 ff = smap.find(s);
48 if (ff == smap.end())
49 return NO_ADDRESS;
50 return ff->second;