From cb1bfc8e2deb46c95ff0a1e49fee401aaba50fdc Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 5 May 2010 16:12:23 +0000 Subject: [PATCH] New function: xbt_dict_cursor_set_data() git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7689 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- ChangeLog | 5 ++++- include/xbt/dict.h | 2 ++ src/xbt/dict_cursor.c | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ac5eb25b5b..f4a8bc0bb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -SimGrid (3.4.2) unstable; urgency=low +SimGrid (3.5) unstable; urgency=low + + XBT + * New function: xbt_dict_cursor_set_data() -- Da SimGrid team diff --git a/include/xbt/dict.h b/include/xbt/dict.h index 3cd77d276f..ffd2174e9f 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -127,6 +127,8 @@ XBT_INLINE XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor); XBT_PUBLIC(char *) xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor); XBT_PUBLIC(void *) xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor); +XBT_PUBLIC(void) xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor, + void *data, void_f_pvoid_t free_ctn); XBT_PUBLIC(void) xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t * cursor); diff --git a/src/xbt/dict_cursor.c b/src/xbt/dict_cursor.c index 5aad0a5949..807e59197e 100644 --- a/src/xbt/dict_cursor.c +++ b/src/xbt/dict_cursor.c @@ -186,3 +186,24 @@ XBT_INLINE void *xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor) return cursor->current->content; } + +/** + * @brief Set current data + * @param cursor the cursor + * @param data the new data + * @param free_ctn the function to free the new data + */ +XBT_INLINE void xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor, + void *data, void_f_pvoid_t free_ctn) +{ + __cursor_not_null(cursor); + if(cursor->current->free_f) + cursor->current->free_f(cursor->current->content); + + cursor->current->content = data; + cursor->current->free_f = free_ctn; + return; +} + + + -- 2.20.1