Esempio n. 1
0
        public binary_library.ISymbol FindSymbol(string s)
        {
            if (bf == null)
            {
                throw new Exception("BinaryFile not set");
            }

            uint hash   = Hash.HashFunction(s);
            long bucket = (long)hash % nbucket;

            r.BaseStream.Seek(bucket_start + bucket * EntrySize(), SeekOrigin.Begin);
            long cur_sym_idx = ReadIntPtr();

            while (cur_sym_idx != 0)
            {
                binary_library.ISymbol cur_sym = bf.GetSymbol((int)cur_sym_idx);
                if (s.Equals(cur_sym.Name))
                {
                    return(cur_sym);
                }

                r.BaseStream.Seek(chain_start + cur_sym_idx * EntrySize(), SeekOrigin.Begin);
                cur_sym_idx = ReadIntPtr();
            }

            return(null);
        }
Esempio n. 2
0
        // Build the hash table
        List <int>[] BuildHashTable(binary_library.IBinaryFile f)
        {
            int sc = f.GetSymbolCount();
            int bc = CalculateBucketCount(sc);

            List <int>[] ht = new List <int> [bc];

            for (int i = 1; i < sc; i++)
            {
                binary_library.ISymbol sym = f.GetSymbol(i);
                uint hash      = HashFunction(sym.Name);
                int  bucket_no = (int)(hash % (uint)bc);

                if (ht[bucket_no] == null)
                {
                    ht[bucket_no] = new List <int>();
                }
                ht[bucket_no].Add(i);
            }

            return(ht);
        }