From 5b951901da126d9e91ac4a8685f69043baf9ff8a Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 1 Oct 2008 14:41:54 +0000 Subject: [PATCH] Add a stupid function to display the content of a dict (as long as it's a string) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5950 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/xbt/dict.h | 1 + src/xbt/dict.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/xbt/dict.h b/include/xbt/dict.h index 9ebe9995d6..03162e7d50 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -64,6 +64,7 @@ SG_BEGIN_DECL(); XBT_PUBLIC(void) xbt_dict_remove(xbt_dict_t dict, const char *key); XBT_PUBLIC(void) xbt_dict_reset(xbt_dict_t dict); XBT_PUBLIC(int) xbt_dict_length(xbt_dict_t dict); + XBT_PUBLIC(void) xbt_dict_dump_output_string(void *s); XBT_PUBLIC(void) xbt_dict_dump(xbt_dict_t dict, void (*output)(void*)); XBT_PUBLIC(void) xbt_dict_dump_sizes(xbt_dict_t dict); diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 9533beb564..649091bb68 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -490,11 +490,17 @@ int xbt_dict_length(xbt_dict_t dict) { return dict->count; } +/** @brief function to be used in xbt_dict_dump as long as the stored values are strings */ +void xbt_dict_dump_output_string(void *s) { + fputs(s,stdout); +} + + /** * \brief Outputs the content of the structure (debugging purpose) * * \param dict the exibitionist - * \param output a function to dump each data in the tree + * \param output a function to dump each data in the tree (check @ref xbt_dict_dump_output_string) * * Outputs the content of the structure. (for debugging purpose). \a output is a * function to output the data. If NULL, data won't be displayed. @@ -511,11 +517,11 @@ void xbt_dict_dump(xbt_dict_t dict, if (element) { printf("[\n"); while (element != NULL) { - printf(" %s -> ", element->key); + printf(" %s -> '", element->key); if (output != NULL) { (*output)(element->content); } - printf("\n"); + printf("'\n"); element = element->next; } printf("]\n"); -- 2.20.1