| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

sym_delete_symbol

#include "sflsymb.h"
SYMBOL *
sym_delete_symbol (
    SYMTAB *table,                      /*  Symbol table to search           */
    SYMBOL *symbol)                     /*  Symbol to delete                 */

Synopsis

Removes the specified symbol from the symbol table and looks through the table for another with the same name. Returns a pointer to the next symbol, or NULL if no further symbols were found with the same name. Deallocates the symbol value, if not NULL. NOTE: The SYMBOL must be part of the symbol table that is being modified.

Source Code - (sflsymb.c)

{
    SYMBOL
        *next;                          /*  Next symbol with same name       */

    ASSERT (table);
    ASSERT (symbol);

    /*  Find a symbol with the same name, or NULL if none found              */
    next = symbol;
    for (next = symbol-> h_next; next; next = next-> h_next)
        if (streq (next-> name, symbol-> name))
            break;

    /*  Fix up the pointers and remove the original symbol                   */
    if (symbol-> prev)
        symbol-> prev-> next = symbol-> next;
    else
        table-> symbols = symbol-> next;

    if (symbol-> next)
        symbol-> next-> prev = symbol-> prev;

    if (symbol-> h_prev)
        symbol-> h_prev-> h_next = symbol-> h_next;
    else
        table-> hash [symbol-> hash] = symbol-> h_next;

    if (symbol-> h_next)
        symbol-> h_next-> h_prev = symbol-> h_prev;

    table-> size--;
    mem_free (symbol-> value);
    mem_free (symbol);

    return (next);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation