#undef xbt_dict_CURSOR_DEBUG
/*#define xbt_dict_CURSOR_DEBUG 1*/
-/** @brief Creator
+/** @brief Creator
* @param dict the dict
*/
xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict) {
/*
* Sanity check to see if the head contains something
*/
-static _XBT_INLINE void __cursor_not_null(xbt_dict_cursor_t cursor) {
+static XBT_INLINE void __cursor_not_null(xbt_dict_cursor_t cursor) {
xbt_assert0(cursor, "Null cursor");
}
* @param[out] cursor dest address
*/
void xbt_dict_cursor_first(const xbt_dict_t dict,
- xbt_dict_cursor_t *cursor){
+ xbt_dict_cursor_t *cursor){
DEBUG0("xbt_dict_cursor_first");
if (!*cursor) {
DEBUG0("Create the cursor on first use");
/**
- * \brief Move to the next element.
+ * \brief Move to the next element.
*/
void xbt_dict_cursor_step(xbt_dict_cursor_t cursor) {
+
+
+ xbt_dictelm_t current ;
+ int line;
+
DEBUG0("xbt_dict_cursor_step");
xbt_assert(cursor);
- xbt_dictelm_t current = cursor->current;
- int line = cursor->line;
+ current = cursor->current;
+ line = cursor->line;
if (cursor->dict != NULL) {
current = current->next;
DEBUG1("next element: %p", current);
}
-
- while (current == NULL && ++line < cursor->dict->table_size) {
+
+ while (current == NULL && ++line <= cursor->dict->table_size) {
DEBUG0("current is NULL, take the next line");
current = cursor->dict->table[line];
DEBUG1("element in the next line: %p", current);
}
DEBUG2("search finished, current = %p, line = %d", current, line);
-
+
cursor->current = current;
cursor->line = line;
}
* @returns true if it's ok, false if there is no more data
*/
int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t *cursor,
- char **key,
- void **data) {
- DEBUG0("xbt_dict_get_or_free");
+ char **key,
+ void **data) {
xbt_dictelm_t current;
+ DEBUG0("xbt_dict_get_or_free");
+
+
if (!cursor || !(*cursor))
return FALSE;
xbt_dict_cursor_free(cursor);
return FALSE;
}
-
+
*key = current->key;
*data = current->content;
return TRUE;