summaryrefslogtreecommitdiffstats
path: root/src/H5FD.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-07 13:32:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-07 13:32:32 (GMT)
commitf766b32d07fae4562e95b9166255c35c8f3e467a (patch)
tree59aa2706ca5c91e1ac4c314a9de9b48f8979dc40 /src/H5FD.c
parent259247fc328fa17b705fc16ab8e004d8c5814ea8 (diff)
downloadhdf5-f766b32d07fae4562e95b9166255c35c8f3e467a.zip
hdf5-f766b32d07fae4562e95b9166255c35c8f3e467a.tar.gz
hdf5-f766b32d07fae4562e95b9166255c35c8f3e467a.tar.bz2
[svn-r7559] Purpose:
Add feature Description: Add H5Fget_freespace() routine, to check the amount of free space in a file. This information is only valid until the file is closed currently, however (until we start recording the free space information in the file itself). Platforms tested: FreeBSD 4.9 (sleipnir) h5committest
Diffstat (limited to 'src/H5FD.c')
-rw-r--r--src/H5FD.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index abc320c..23ad863 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -3372,3 +3372,50 @@ herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle)
done:
FUNC_LEAVE_NOAPI(ret_value)
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_get_freespace
+ *
+ * Purpose: Retrieve the amount of free space in a file.
+ *
+ * Return: Success: Amount of free space in file
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, October 6, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hssize_t
+H5FD_get_freespace(H5FD_t *file)
+{
+ H5FD_free_t *free_node; /* Pointer to node on free list */
+ H5FD_mem_t type; /* Type of memory */
+ hssize_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_get_freespace, FAIL)
+
+ /* check args */
+ assert(file);
+ assert(file->cls);
+
+ /* Initialize return value */
+ ret_value=0;
+
+ /* Iterate over all the types of memory, to retrieve amount of free space for each */
+ for (type=H5FD_MEM_DEFAULT; type<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,type)) {
+ /* Iterate through the free list, accumulating the amount of free space for this type */
+ free_node = file->fl[type];
+ while(free_node) {
+ ret_value+=free_node->size;
+ free_node=free_node->next;
+ } /* end while */
+ } /* end for */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_get_freespace() */
+