Changeset 440

Show
Ignore:
Timestamp:
2004-07-12 22:59:14 (4 years ago)
Author:
conrad
Message:

added oggz_table_remove function

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggz/trunk/include/oggz/oggz_table.h

    r350 r440  
    7272 
    7373/** 
     74 * Remove the element of an OggzTable indexed by a given key 
     75 * \param table An OggzTable 
     76 * \param key a key 
     77 * \retval 0 Success 
     78 * \retval -1 Not found 
     79 */ 
     80int 
     81oggz_table_remove (OggzTable * table, long key); 
     82 
     83/** 
    7484 * Retrieve the element of an OggzTable indexed by a given key 
    7585 * \param table An OggzTable 
     
    90100 
    91101/** 
    92  * Retrieve the nth element of an OggzTable 
     102 * Retrieve the nth element of an OggzTable, and optionally its key 
    93103 * \param table An OggzTable 
    94104 * \param n An index into the \a table 
    95  * \param key Return value for key corresponding to nth data element 
    96  *        of \a table 
     105 * \param key Return pointer for key corresponding to nth data element 
     106 *        of \a table. Ignored if NULL. 
    97107 * \returns The nth data element of \a table 
    98108 * \retval NULL \a table is undefined, or \a n is out of range 
  • liboggz/trunk/src/liboggz/Version_script.in

    r406 r440  
    4848                oggz_table_delete; 
    4949                oggz_table_insert; 
     50                oggz_table_remove; 
    5051                oggz_table_lookup; 
    5152                oggz_table_size; 
  • liboggz/trunk/src/liboggz/oggz_table.c

    r347 r440  
    108108 
    109109int 
     110oggz_table_remove (OggzTable * table, long key) 
     111{ 
     112  void * old_data; 
     113 
     114  if ((old_data = oggz_table_lookup (table, key)) != NULL) { 
     115    if (oggz_vector_remove_l (table->keys, key) == NULL) 
     116      return -1; 
     117 
     118    if (oggz_vector_remove_p (table->data, old_data) == NULL) { 
     119      /* XXX: This error condition can only happen if the previous 
     120       * removal succeeded, and this removal failed, ie. there was 
     121       * an error reallocing table->data->data downwards. */ 
     122      return -1; 
     123    } 
     124  } 
     125   
     126  return 0; 
     127} 
     128 
     129int 
    110130oggz_table_size (OggzTable * table) 
    111131{