flush.c 901 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * \file flush.c
  3. *
  4. * \brief Segment flush routines.
  5. *
  6. * This program is free software under the GNU General Public License
  7. * (>=v2). Read the file COPYING that comes with GRASS for details.
  8. *
  9. * \author GRASS GIS Development Team
  10. *
  11. * \date 2005-2009
  12. */
  13. #include "local_proto.h"
  14. /**
  15. * \fn int Segment_flush (SEGMENT *SEG)
  16. *
  17. * \brief Flush pending updates to disk.
  18. *
  19. * Forces all pending updates generated by <i>Segment_put()</i> to be
  20. * written to the segment file <b>seg</b>. Must be called after the
  21. * final <i>Segment_put()</i> to force all pending updates to disk. Must
  22. * also be called before the first call to <i>Segment_get_row</i>.
  23. *
  24. * \param[in] SEG segment
  25. * \return always returns 0
  26. */
  27. int Segment_flush(SEGMENT * SEG)
  28. {
  29. int i;
  30. for (i = 0; i < SEG->nseg; i++)
  31. if (SEG->scb[i].n >= 0 && SEG->scb[i].dirty)
  32. seg_pageout(SEG, i);
  33. return 0;
  34. }