T.I.M | Toolchain Documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
asm_hash_table.c File Reference

Contains all functions that operate on the asm_hash_table datastructure. More...

#include "asm.h"

Functions

void asm_hash_table_new (int initial_size, asm_hash_table *tr)
 Creates and returns a new pointer to a hash table. More...
 
int asm_hash_table_expand (asm_hash_table *table, int new_size)
 
asm_hash_key asm_hash_key_string (char *string, int table_size)
 Returns a hash key of a string. More...
 
int asm_hash_table_insert (asm_hash_table *table, char *key, void *data)
 Inserts an element into the hash table associated with the provided key. More...
 
void * asm_hash_table_get (asm_hash_table *table, char *strkey)
 Returns a pointer to the data stored in a hash table with the given key or NULL if no such element exists. More...
 

Detailed Description

Contains all functions that operate on the asm_hash_table datastructure.

Function Documentation

asm_hash_key asm_hash_key_string ( char *  string,
int  table_size 
)

Returns a hash key of a string.

Referenced by asm_hash_table_get(), and asm_hash_table_insert().

int asm_hash_table_expand ( asm_hash_table table,
int  new_size 
)

References warning.

void* asm_hash_table_get ( asm_hash_table table,
char *  strkey 
)

Returns a pointer to the data stored in a hash table with the given key or NULL if no such element exists.

Parameters
table- The table to fetch the data from.
strkey- The key to the data to fetch.
Todo:
Make sure the key fits into the table.

References asm_hash_key_string(), and asm_hash_table::current_size.

Referenced by asm_calculate_addresses().

int asm_hash_table_insert ( asm_hash_table table,
char *  key,
void *  data 
)

Inserts an element into the hash table associated with the provided key.

Parameters
table- Pointer to the hash table to insert into.
key- The key to the data.
data- Pointer to the data the table will contain.
Returns
a status code. Zero if it worked, otherwise some integer.
Todo:
Check that the key will fit!!

References asm_hash_key_string().

Referenced by asm_parse_label_declaration().

void asm_hash_table_new ( int  initial_size,
asm_hash_table tr 
)

Creates and returns a new pointer to a hash table.

Parameters
initial_size- The initial size of the hash table's internal data structure.
tr- The newly initialised and returned hashtable. Memory space should already be declared.

Referenced by main().