-/* $Id$ */
-
/* set - data container consisting in dict+dynar */
-/* Copyright (c) 2004 Martin Quinson. All rights reserved. */
+/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+ * All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
* if elm->name_len <= 0, it is recomputed. If >0, it's used as is;
* elm->ID is attributed automatically.
*/
-void xbt_set_add(xbt_set_t set, xbt_set_elm_t elm, void_f_pvoid_t free_func)
+void xbt_set_add(xbt_set_t set, xbt_set_elm_t elm,
+ void_f_pvoid_t free_func)
{
int found = 1;
if (found) {
if (elm == found_in_dict) {
DEBUG2
- ("Ignoring request to insert the same element twice (key %s ; id %d)",
- elm->name, elm->ID);
+ ("Ignoring request to insert the same element twice (key %s ; id %d)",
+ elm->name, elm->ID);
return;
} else {
elm->ID = found_in_dict->ID;
DEBUG2("Reinsertion of key %s (id %d)", elm->name, elm->ID);
- xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func);
+ xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm,
+ free_func);
xbt_dynar_set(set->dynar, elm->ID, &elm);
return;
}
* \param key name of the element to remove
* \param key_len length of \a name
*/
-void xbt_set_remove_by_name_ext(xbt_set_t set, const char *key, int key_len)
+void xbt_set_remove_by_name_ext(xbt_set_t set, const char *key,
+ int key_len)
{
xbt_set_elm_t elm = xbt_set_get_by_name_ext(set, key, key_len);
xbt_set_remove(set, elm);
* \param name Name of the searched cell
* \returns the data you're looking for, returns NULL if not found
*/
-xbt_set_elm_t xbt_set_get_by_name_or_null (xbt_set_t set,
- const char *name) {
- DEBUG1("Lookup key %s",name);
+xbt_set_elm_t xbt_set_get_by_name_or_null(xbt_set_t set, const char *name)
+{
+ DEBUG1("Lookup key %s", name);
return xbt_dict_get_or_null(set->dict, name);
}
if (!*cursor) {
DEBUG0("Create the cursor on first use");
*cursor = xbt_new(s_xbt_set_cursor_t, 1);
- xbt_assert0(*cursor, "Malloc error during the creation of the cursor");
+ xbt_assert0(*cursor,
+ "Malloc error during the creation of the cursor");
}
(*cursor)->set = set;
*
* \return true if it's ok, false if there is no more data
*/
-int xbt_set_cursor_get_or_free(xbt_set_cursor_t * curs, xbt_set_elm_t * elm)
+int xbt_set_cursor_get_or_free(xbt_set_cursor_t * curs,
+ xbt_set_elm_t * elm)
{
xbt_set_cursor_t cursor;
THROW2(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
key, elm->name);
if (strcmp(elm->name, elm->data))
- THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key, elm->name);
+ THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key,
+ elm->name);
fflush(stdout);
}
xbt_test_assert0(elm, "Dude ! Got a null elm during traversal!");
xbt_test_log3("Id(%d): %s->%s\n", elm->ID, elm->name, elm->data);
xbt_test_assert2(!strcmp(elm->name, elm->data),
- "Key(%s) != value(%s). Abording", elm->name, elm->data);
+ "Key(%s) != value(%s). Abording", elm->name,
+ elm->data);
}
}
xbt_test_add1("Search %s (expected not to be found)", data);
TRY {
xbt_set_get_by_name(set, data);
- THROW1(unknown_error, 0, "Found something which shouldn't be there (%s)",
- data);
+ THROW1(unknown_error, 0,
+ "Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_test_assert1(elm->ID == 1, "elm->ID is %d but should be 1", elm->ID);
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */