summaryrefslogtreecommitdiffstats
path: root/src/H5FS.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-08-20 18:09:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-08-20 18:09:28 (GMT)
commit96b3c145b7b8e033fff6504a5dbb88c78c42219b (patch)
treeffc018237d328eb5b4444d20eba7f52945d818d3 /src/H5FS.c
parentd29082f1659e2b5faa5fda61003b792cc5c9c4c7 (diff)
downloadhdf5-96b3c145b7b8e033fff6504a5dbb88c78c42219b.zip
hdf5-96b3c145b7b8e033fff6504a5dbb88c78c42219b.tar.gz
hdf5-96b3c145b7b8e033fff6504a5dbb88c78c42219b.tar.bz2
[svn-r11282] Purpose:
New debugging feature Description: Add some code to track where memory from the internal free list allocator is allocated within the library. It's not quite ready for "prime time" yet, but it's close enough to be useful. This is disabled by default and requires the H5FL_TRACK macro in src/H5FLprivate.h to be uncommented to activate during debugging. Platforms tested: FreeBSD 4.11 (sleipnir) Linux 2.4 Too minor to require full h5committest
Diffstat (limited to 'src/H5FS.c')
-rw-r--r--src/H5FS.c117
1 files changed, 108 insertions, 9 deletions
diff --git a/src/H5FS.c b/src/H5FS.c
index 63928dd..83c4020 100644
--- a/src/H5FS.c
+++ b/src/H5FS.c
@@ -27,8 +27,9 @@
*/
-#include "H5private.h" /* Generic Functions */
-#include "H5FSprivate.h" /* Private function stack routines */
+#include "H5private.h" /* Generic Functions */
+#include "H5FSprivate.h" /* Function stack */
+#include "H5MMprivate.h" /* Memory management */
#ifdef H5_HAVE_FUNCSTACK
@@ -93,31 +94,30 @@ H5FS_get_stack(void)
/*-------------------------------------------------------------------------
- * Function: H5FS_print
+ * Function: H5FS_print_stack
*
- * Purpose: Prints the function stack in some default way.
+ * Purpose: Prints a function stack.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
- * THursday, February 6, 2003
+ * Thursday, February 6, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5FS_print(FILE *stream)
+H5FS_print_stack(const H5FS_t *fstack, FILE *stream)
{
- H5FS_t *fstack = H5FS_get_my_stack (); /* Get the correct function stack */
const int indent = 2; /* Indention level */
int i; /* Local index ariable */
/* Don't push this function on the function stack... :-) */
- FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_print);
+ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_print_stack);
/* Sanity check */
- assert(fstack);
+ HDassert(fstack);
/* Default to outputting information to stderr */
if (!stream)
@@ -138,6 +138,37 @@ H5FS_print(FILE *stream)
HDfprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->slot[i]);
FUNC_LEAVE_NOAPI_NOFS(SUCCEED);
+} /* end H5FS_print_stack() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FS_print
+ *
+ * Purpose: Prints the default function stack in some default way.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, February 6, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FS_print(FILE *stream)
+{
+ H5FS_t *fstack = H5FS_get_my_stack (); /* Get the correct function stack */
+
+ /* Don't push this function on the function stack... :-) */
+ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_print);
+
+ /* Sanity check */
+ assert(fstack);
+
+ H5FS_print_stack(fstack, stream);
+
+ FUNC_LEAVE_NOAPI_NOFS(SUCCEED);
} /* end H5FS_print() */
@@ -211,4 +242,72 @@ H5FS_pop(void)
FUNC_LEAVE_NOAPI_NOFS(SUCCEED);
} /* end H5FS_pop() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FS_copy_stack
+ *
+ * Purpose: Makes a copy of the current stack
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, August 9, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FS_copy_stack(H5FS_t *new_stack)
+{
+ H5FS_t *old_stack = H5FS_get_my_stack ();
+ unsigned u; /* Local index variable */
+
+ /* Don't push this function on the function stack... :-) */
+ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_copy_stack);
+
+ /* Sanity check */
+ HDassert (old_stack);
+
+ /* Copy old stack to new one, duplicating the strings */
+ for(u = 0; u < old_stack->nused; u++)
+ new_stack->slot[u] = H5MM_strdup(old_stack->slot[u]);
+ new_stack->nused = old_stack->nused;
+
+ FUNC_LEAVE_NOAPI_NOFS(SUCCEED);
+} /* end H5FS_copy_stack() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FS_close_stack
+ *
+ * Purpose: Closes a copy of a stack
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, August 9, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FS_close_stack(H5FS_t *stack)
+{
+ unsigned u; /* Local index variable */
+
+ /* Don't push this function on the function stack... :-) */
+ FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5FS_close_stack);
+
+ /* Sanity check */
+ HDassert (stack);
+
+ /* Free strings on stack */
+ for(u = 0; u < stack->nused; u++)
+ stack->slot[u] = H5MM_xfree(stack->slot[u]);
+
+ FUNC_LEAVE_NOAPI_NOFS(SUCCEED);
+} /* end H5FS_close_stack() */
+
#endif /* H5_HAVE_FUNCSTACK */