00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #include "dbprim.h"
00029 #include "dbprim_int.h"
00030
00031 RCSTAG("@(#)$Id: sh_flush.c,v 1.3 2006/07/13 19:16:24 klmitch Exp $");
00032
00041 struct _sh_flush_s {
00042 smat_table_t *sf_table;
00043 smat_loc_t sf_elem;
00044 smat_iter_t sf_flush;
00045 void *sf_extra;
00046 };
00047
00066 static unsigned long
00067 _sh_flush_iter(link_head_t *head, link_elem_t *elem, void *extra)
00068 {
00069 unsigned long retval = 0;
00070 struct _sh_flush_s *sf;
00071
00072 sf = extra;
00073
00074
00075 if (_st_remove(sf->sf_table, le_object(elem), ST_REM_HASH |
00076 (sf->sf_elem == SMAT_LOC_FIRST ? ST_REM_SECOND :
00077 ST_REM_FIRST)))
00078 return DB_ERR_UNRECOVERABLE;
00079
00080
00081 if (sf->sf_flush)
00082 retval = (*sf->sf_flush)(sf->sf_table, le_object(elem), sf->sf_extra);
00083
00084 _smat_free(le_object(elem));
00085
00086 return retval;
00087 }
00088
00089 unsigned long
00090 sh_flush(smat_head_t *head, smat_iter_t flush_func, void *extra)
00091 {
00092 struct _sh_flush_s sf;
00093
00094 initialize_dbpr_error_table();
00095
00096 if (!sh_verify(head))
00097 return DB_ERR_BADARGS;
00098
00099
00100 sf.sf_table = head->sh_table;
00101 sf.sf_elem = head->sh_elem;
00102 sf.sf_flush = flush_func;
00103 sf.sf_extra = extra;
00104
00105
00106 return ll_flush(&head->sh_head, _sh_flush_iter, &sf);
00107 }