Back to index

cell-binutils  2.17cvs20070401
Functions
hash.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void set_gas_hash_table_size (unsigned long)
struct hash_controlhash_new (void)
void hash_die (struct hash_control *)
const char * hash_insert (struct hash_control *, const char *key, PTR value)
const char * hash_jam (struct hash_control *, const char *key, PTR value)
PTR hash_replace (struct hash_control *, const char *key, PTR value)
PTR hash_find (struct hash_control *, const char *key)
PTR hash_find_n (struct hash_control *, const char *key, size_t len)
PTR hash_delete (struct hash_control *, const char *key)
void hash_traverse (struct hash_control *, void(*pfn)(const char *key, PTR value))
void hash_print_statistics (FILE *, const char *name, struct hash_control *)

Function Documentation

PTR hash_delete ( struct hash_control ,
const char *  key 
)

Definition at line 348 of file hash.c.

{
  struct hash_entry *p;
  struct hash_entry **list;

  p = hash_lookup (table, key, strlen (key), &list, NULL);
  if (p == NULL)
    return NULL;

  if (p != *list)
    abort ();

#ifdef HASH_STATISTICS
  ++table->deletions;
#endif

  *list = p->next;

  /* Note that we never reclaim the memory for this entry.  If gas
     ever starts deleting hash table entries in a big way, this will
     have to change.  */

  return p->data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 138 of file hash.c.

{
  obstack_free (&table->memory, 0);
  free (table);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PTR hash_find ( struct hash_control ,
const char *  key 
)

Definition at line 318 of file hash.c.

{
  struct hash_entry *p;

  p = hash_lookup (table, key, strlen (key), NULL, NULL);
  if (p == NULL)
    return NULL;

  return p->data;
}

Here is the call graph for this function:

PTR hash_find_n ( struct hash_control ,
const char *  key,
size_t  len 
)

Definition at line 333 of file hash.c.

{
  struct hash_entry *p;

  p = hash_lookup (table, key, len, NULL, NULL);
  if (p == NULL)
    return NULL;

  return p->data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* hash_insert ( struct hash_control ,
const char *  key,
PTR  value 
)

Definition at line 226 of file hash.c.

{
  struct hash_entry *p;
  struct hash_entry **list;
  unsigned long hash;

  p = hash_lookup (table, key, strlen (key), &list, &hash);
  if (p != NULL)
    return "exists";

#ifdef HASH_STATISTICS
  ++table->insertions;
#endif

  p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof (*p));
  p->string = key;
  p->hash = hash;
  p->data = value;

  p->next = *list;
  *list = p;

  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* hash_jam ( struct hash_control ,
const char *  key,
PTR  value 
)

Definition at line 256 of file hash.c.

{
  struct hash_entry *p;
  struct hash_entry **list;
  unsigned long hash;

  p = hash_lookup (table, key, strlen (key), &list, &hash);
  if (p != NULL)
    {
#ifdef HASH_STATISTICS
      ++table->replacements;
#endif

      p->data = value;
    }
  else
    {
#ifdef HASH_STATISTICS
      ++table->insertions;
#endif

      p = (struct hash_entry *) obstack_alloc (&table->memory, sizeof (*p));
      p->string = key;
      p->hash = hash;
      p->data = value;

      p->next = *list;
      *list = p;
    }

  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct hash_control* hash_new ( void  ) [read]

Definition at line 108 of file hash.c.

{
  unsigned long size;
  unsigned long alloc;
  struct hash_control *ret;

  size = get_gas_hash_table_size ();

  ret = xmalloc (sizeof *ret);
  obstack_begin (&ret->memory, chunksize);
  alloc = size * sizeof (struct hash_entry *);
  ret->table = obstack_alloc (&ret->memory, alloc);
  memset (ret->table, 0, alloc);
  ret->size = size;

#ifdef HASH_STATISTICS
  ret->lookups = 0;
  ret->hash_compares = 0;
  ret->string_compares = 0;
  ret->insertions = 0;
  ret->replacements = 0;
  ret->deletions = 0;
#endif

  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hash_print_statistics ( FILE *  ,
const char *  name,
struct hash_control  
)
PTR hash_replace ( struct hash_control ,
const char *  key,
PTR  value 
)

Definition at line 294 of file hash.c.

{
  struct hash_entry *p;
  PTR ret;

  p = hash_lookup (table, key, strlen (key), NULL, NULL);
  if (p == NULL)
    return NULL;

#ifdef HASH_STATISTICS
  ++table->replacements;
#endif

  ret = p->data;

  p->data = value;

  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hash_traverse ( struct hash_control ,
void(*)(const char *key, PTR value pfn 
)

Definition at line 377 of file hash.c.

{
  unsigned int i;

  for (i = 0; i < table->size; ++i)
    {
      struct hash_entry *p;

      for (p = table->table[i]; p != NULL; p = p->next)
       (*pfn) (p->string, p->data);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file hash.c.

{
  gas_hash_table_size = size;
}

Here is the caller graph for this function: