Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

st_remove.c

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
00003 **
00004 ** This library is free software; you can redistribute it and/or
00005 ** modify it under the terms of the GNU Library General Public
00006 ** License as published by the Free Software Foundation; either
00007 ** version 2 of the License, or (at your option) any later version.
00008 **
00009 ** This library is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 ** Library General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU Library General Public
00015 ** License along with this library; if not, write to the Free
00016 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00017 ** MA 02111-1307, USA
00018 **
00019 ** @(#)$Id: st_remove.c,v 1.3 2006/07/13 19:16:24 klmitch Exp $
00020 */
00029 #include "dbprim.h"
00030 #include "dbprim_int.h"
00031 
00032 RCSTAG("@(#)$Id: st_remove.c,v 1.3 2006/07/13 19:16:24 klmitch Exp $");
00033 
00034 unsigned long
00035 _st_remove(smat_table_t *table, smat_entry_t *entry, unsigned int remflag)
00036 {
00037   unsigned long retval;
00038 
00039   if (remflag & ST_REM_HASH) { /* remove from hash table */
00040     if ((retval = ht_remove(&table->st_table, &entry->se_hash)))
00041       return retval;
00042   }
00043 
00044   if (remflag & ST_REM_FIRST) { /* remove from first linked list */
00045     if ((retval = ll_remove(entry->se_link[SMAT_LOC_FIRST].le_head,
00046                             &entry->se_link[SMAT_LOC_FIRST])))
00047       return retval;
00048   }
00049 
00050   if (remflag & ST_REM_SECOND) { /* remove from second linked list */
00051     if ((retval = ll_remove(entry->se_link[SMAT_LOC_SECOND].le_head,
00052                             &entry->se_link[SMAT_LOC_SECOND])))
00053       return retval;
00054   }
00055 
00056   if (remflag & ST_REM_FREE) /* free entry */
00057     _smat_free(entry);
00058 
00059   return 0;
00060 }
00061 
00062 unsigned long
00063 st_remove(smat_table_t *table, smat_entry_t *entry)
00064 {
00065   initialize_dbpr_error_table(); /* initialize error table */
00066 
00067   /* verify arguments */
00068   if (!st_verify(table) || !se_verify(entry))
00069     return DB_ERR_BADARGS;
00070 
00071   /* verify entry is in this table */
00072   if (entry->se_table != table)
00073     return DB_ERR_WRONGTABLE;
00074 
00075   /* remove the entry from the linked lists and from the hash table */
00076   if (_st_remove(table, entry, (ST_REM_HASH | ST_REM_FIRST | ST_REM_SECOND |
00077                                 ST_REM_FREE)))
00078     return DB_ERR_UNRECOVERABLE;
00079 
00080   return 0;
00081 }

Generated on Sat Jul 15 14:10:33 2006 for DatabasePrimitivesLibrary by  doxygen 1.4.4