oggz_table.h File Reference
A lookup table.  
More...
Go to the source code of this file.
Detailed Description
A lookup table. 
OggzTable is provided for convenience to allow the storage of serialno-specific data. 
Function Documentation
Delete an OggzTable. 
- Parameters:
 - 
  
  
 
 
 
      
        
          | void* oggz_table_insert  | 
          ( | 
          OggzTable *  | 
           table,  | 
        
        
           | 
           | 
          long  | 
           key,  | 
        
        
           | 
           | 
          void *  | 
           data |   | 
        
        
           | 
          ) | 
           |  |  | 
        
      
 
Insert an element into a table. 
If a previous value existed for this key, it is overwritten with the new data element. 
- Parameters:
 - 
  
     | table  | An OggzTable  | 
     | key  | Key to access this data element  | 
     | data  | The new element to add  | 
  
   
- Return values:
 - 
  
     | data  | If the element was successfully added  | 
     | NULL  | If adding the element failed due to a realloc() error  | 
  
   
 
 
      
        
          | void* oggz_table_lookup  | 
          ( | 
          OggzTable *  | 
           table,  | 
        
        
           | 
           | 
          long  | 
           key |   | 
        
        
           | 
          ) | 
           |  |  | 
        
      
 
Retrieve the element of an OggzTable indexed by a given key. 
- Parameters:
 - 
  
     | table  | An OggzTable  | 
     | key  | a key  | 
  
   
- Returns:
 - The element indexed by key 
 
- Return values:
 - 
  
     | NULL  | table is undefined, or no element is indexed by key  | 
  
   
 
 
Instantiate a new OggzTable. 
- Returns:
 - A new OggzTable 
 
- Return values:
 - 
  
     | NULL  | Could not allocate memory for table  | 
  
   
 
 
      
        
          | void* oggz_table_nth  | 
          ( | 
          OggzTable *  | 
           table,  | 
        
        
           | 
           | 
          int  | 
           n,  | 
        
        
           | 
           | 
          long *  | 
           key |   | 
        
        
           | 
          ) | 
           |  |  | 
        
      
 
Retrieve the nth element of an OggzTable, and optionally its key. 
- Parameters:
 - 
  
     | table  | An OggzTable  | 
     | n  | An index into the table  | 
     | key  | Return pointer for key corresponding to nth data element of table. Ignored if NULL.  | 
  
   
- Returns:
 - The nth data element of table 
 
- Return values:
 - 
  
     | NULL  | table is undefined, or n is out of range  | 
  
   
 
 
      
        
          | int oggz_table_remove  | 
          ( | 
          OggzTable *  | 
           table,  | 
        
        
           | 
           | 
          long  | 
           key |   | 
        
        
           | 
          ) | 
           |  |  | 
        
      
 
Remove the element of an OggzTable indexed by a given key. 
- Parameters:
 - 
  
     | table  | An OggzTable  | 
     | key  | a key  | 
  
   
- Return values:
 - 
  
  
 
 
 
Query the number of elements in an OggzTable. 
- Parameters:
 - 
  
  
 
- Returns:
 - the number of elements in table