2 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Library General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2 of the License, or (at your option) any later version.
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Library General Public License for more details.
14 ** You should have received a copy of the GNU Library General Public
15 ** License along with this library; if not, write to the Free
16 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 #include "dbprim_int.h"
27 _st_remove(smat_table_t *table, smat_entry_t *entry, unsigned int remflag)
31 if (remflag & ST_REM_HASH) { /* remove from hash table */
32 if ((retval = ht_remove(&table->st_table, &entry->se_hash)))
36 if (remflag & ST_REM_FIRST) { /* remove from first linked list */
37 if ((retval = ll_remove(entry->se_link[SMAT_LOC_FIRST].le_head,
38 &entry->se_link[SMAT_LOC_FIRST])))
42 if (remflag & ST_REM_SECOND) { /* remove from second linked list */
43 if ((retval = ll_remove(entry->se_link[SMAT_LOC_SECOND].le_head,
44 &entry->se_link[SMAT_LOC_SECOND])))
48 if (remflag & ST_REM_FREE) /* free entry */
54 /** \ingroup dbprim_smat
55 * \brief Remove an entry from a sparse matrix.
57 * This function removes the given entry from the specified sparse
60 * \param table A pointer to a #smat_table_t.
61 * \param entry A pointer to a #smat_entry_t to be removed from the
64 * \retval DB_ERR_BADARGS An invalid argument was given.
65 * \retval DB_ERR_WRONGTABLE Entry is not in this sparse matrix.
66 * \retval DB_ERR_UNRECOVERABLE An unrecoverable error occurred while
67 * removing the entry from the table.
70 st_remove(smat_table_t *table, smat_entry_t *entry)
72 initialize_dbpr_error_table(); /* initialize error table */
74 /* verify arguments */
75 if (!st_verify(table) || !se_verify(entry))
76 return DB_ERR_BADARGS;
78 /* verify entry is in this table */
79 if (entry->se_table != table)
80 return DB_ERR_WRONGTABLE;
82 /* remove the entry from the linked lists and from the hash table */
83 if (_st_remove(table, entry, (ST_REM_HASH | ST_REM_FIRST | ST_REM_SECOND |
85 return DB_ERR_UNRECOVERABLE;