release.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * \file lib/segment/release.c
  3. *
  4. * \brief Segment release 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 <stdlib.h>
  14. #include <grass/gis.h>
  15. #include "local_proto.h"
  16. /**
  17. * \fn int Segment_release (SEGMENT *SEG)
  18. *
  19. * \brief Free memory allocated to segment.
  20. *
  21. * Releases the allocated memory associated with the segment file
  22. * <b>seg</b>.
  23. *
  24. * <b>Note:</b> Does not close the file. Does not flush the data which
  25. * may be pending from previous <i>Segment_put()</i> calls.
  26. *
  27. * \param[in,out] SEG segment
  28. * \return 1 if successful
  29. * \return -1 if SEGMENT is not available (not open)
  30. */
  31. int Segment_release(SEGMENT * SEG)
  32. {
  33. int i;
  34. if (SEG->open != 1)
  35. return -1;
  36. for (i = 0; i < SEG->nseg; i++)
  37. G_free(SEG->scb[i].buf);
  38. G_free(SEG->scb);
  39. G_free(SEG->freeslot);
  40. G_free(SEG->agequeue);
  41. G_free(SEG->load_idx);
  42. SEG->open = 0;
  43. return 1;
  44. }