1.13.4. sym_LookupSymbol()

[<<<] [>>>]

This function should be used to search a symbol or to insert a new symbol.

void **sym_LookupSymbol(
  char *s,                 /* zero terminated string containing the symbol                 */
  SymbolTable hashtable,   /* the symbol table                                             */
  int insert,              /* should a new empty symbol inserted, or return NULL instead   */
  void* (*memory_allocating_function)(size_t, void *),
  void (*memory_releasing_function)(void *, void *),
  void *pMemorySegment
);

This function usually returns a pointer to the void * pointer which is supposed to point to the structure, which actually holds the parameters for the symbol. When a symbol is not found in the symbol table the parameter insert is used to decide what to do. If this parameter is zero the function returns NULL. If this parameter is 1 the function creates a new symbol and returns a pointer to the void * pointer associated with the symbol.

If a new symbol is to be inserted and the function returns NULL means that the memory allocation function has failed.

If the new symbol was created and a pointer to the void * pointer is returned the value of the pointer is NULL. In other words:

void **a;

a = sym_LookupSymbol(s,table,1,mymema,mymemr,p);

if( a == NULL )error("memory releasing error"); if( *a == NULL )error("symbol not found");


[<<<] [>>>]