A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace a new/free cycle by a locally stacked object
[simgrid.git]
/
src
/
xbt
/
dict.c
diff --git
a/src/xbt/dict.c
b/src/xbt/dict.c
index 75180751571b59b9f69378ce9580693d24f13ef6..c58f0c0882fc951bb55dd461f346a8cc9a72daaa 100644
(file)
--- a/
src/xbt/dict.c
+++ b/
src/xbt/dict.c
@@
-223,8
+223,8
@@
static void xbt_dict_rehash(xbt_dict_t dict)
* \param key the key to set the new data
* \param key_len the size of the \a key
* \param data the data to add in the dict
* \param key the key to set the new data
* \param key_len the size of the \a key
* \param data the data to add in the dict
- * \param free_ctn function to call with (\a
key
as argument) when
- * \a
key
is removed from the dictionary
+ * \param free_ctn function to call with (\a
data
as argument) when
+ * \a
data
is removed from the dictionary
*
* Set the \a data in the structure under the \a key, which can be any kind
* of data, as long as its length is provided in \a key_len.
*
* Set the \a data in the structure under the \a key, which can be any kind
* of data, as long as its length is provided in \a key_len.
@@
-281,8
+281,8
@@
XBT_INLINE void xbt_dict_set_ext(xbt_dict_t dict,
* \param dict the dict
* \param key the key to set the new data
* \param data the data to add in the dict
* \param dict the dict
* \param key the key to set the new data
* \param data the data to add in the dict
- * \param free_ctn function to call with (\a
key
as argument) when
- * \a
key
is removed from the dictionary
+ * \param free_ctn function to call with (\a
data
as argument) when
+ * \a
data
is removed from the dictionary
*
* set the \a data in the structure under the \a key, which is a
* null terminated string.
*
* set the \a data in the structure under the \a key, which is a
* null terminated string.
@@
-323,7
+323,7
@@
XBT_INLINE void *xbt_dict_get_ext(xbt_dict_t dict, const char *key,
}
if (current == NULL)
}
if (current == NULL)
- THROW
2
(not_found_error, 0, "key %.*s not found", key_len, key);
+ THROW
F
(not_found_error, 0, "key %.*s not found", key_len, key);
return current->content;
}
return current->content;
}
@@
-401,7
+401,7
@@
XBT_INLINE void *xbt_dict_get(xbt_dict_t dict, const char *key)
current = current->next;
if (current == NULL)
current = current->next;
if (current == NULL)
- THROW
1
(not_found_error, 0, "key %s not found", key);
+ THROW
F
(not_found_error, 0, "key %s not found", key);
return current->content;
}
return current->content;
}
@@
-457,7
+457,7
@@
XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key,
}
if (current == NULL)
}
if (current == NULL)
- THROW
2
(not_found_error, 0, "key %.*s not found", key_len, key);
+ THROW
F
(not_found_error, 0, "key %.*s not found", key_len, key);
if (previous != NULL) {
previous->next = current->next;
if (previous != NULL) {
previous->next = current->next;
@@
-591,7
+591,7
@@
XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key)
}
if (current == NULL)
}
if (current == NULL)
- THROW
1
(not_found_error, 0, "key %zu not found", key);
+ THROW
F
(not_found_error, 0, "key %zu not found", key);
if (previous != NULL) {
previous->next = current->next;
if (previous != NULL) {
previous->next = current->next;
@@
-658,7
+658,7
@@
void xbt_dict_dump_output_string(void *s)
*/
XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
{
*/
XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
{
- return
(xbt_dict_size
(dict) == 0);
+ return
!dict || (xbt_dict_length
(dict) == 0);
}
/**
}
/**
@@
-684,7
+684,7
@@
void xbt_dict_dump(xbt_dict_t dict, void_f_pvoid_t output)
while (element != NULL) {
printf(" %s -> '", element->key);
if (output != NULL) {
while (element != NULL) {
printf(" %s -> '", element->key);
if (output != NULL) {
-
(*output)
(element->content);
+
output
(element->content);
}
printf("'\n");
element = element->next;
}
printf("'\n");
element = element->next;
@@
-939,9
+939,10
@@
static void search_not_found(xbt_dict_t head, const char *data)
TRY {
data = xbt_dict_get(head, data);
TRY {
data = xbt_dict_get(head, data);
- THROW
1
(unknown_error, 0,
+ THROW
F
(unknown_error, 0,
"Found something which shouldn't be there (%s)", data);
"Found something which shouldn't be there (%s)", data);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
@@
-974,7
+975,8
@@
static void count(xbt_dict_t dict, int length)
static void count_check_get_key(xbt_dict_t dict, int length)
{
xbt_dict_cursor_t cursor;
static void count_check_get_key(xbt_dict_t dict, int length)
{
xbt_dict_cursor_t cursor;
- char *key, *key2;
+ char *key;
+ _XBT_GNUC_UNUSED char *key2;
void *data;
int effective = 0;
void *data;
int effective = 0;
@@
-989,7
+991,7
@@
static void count_check_get_key(xbt_dict_t dict, int length)
xbt_dict_foreach(dict, cursor, key, data) {
effective++;
key2 = xbt_dict_get_key(dict, data);
xbt_dict_foreach(dict, cursor, key, data) {
effective++;
key2 = xbt_dict_get_key(dict, data);
- xbt_assert
2
(!strcmp(key, key2),
+ xbt_assert(!strcmp(key, key2),
"The data was registered under %s instead of %s as expected",
key2, key);
}
"The data was registered under %s instead of %s as expected",
key2, key);
}
@@
-1014,7
+1016,8
@@
XBT_TEST_UNIT("basic", test_dict_basic, "Basic usage: change, retrieve, traverse
traverse(head);
TRY {
debuged_remove(head, "12346");
traverse(head);
TRY {
debuged_remove(head, "12346");
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
@@
-1248,7
+1251,7
@@
static int countelems(xbt_dict_t head)
XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
{
xbt_dict_t head = NULL;
XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
{
xbt_dict_t head = NULL;
- int i, j, k
, nb
;
+ int i, j, k;
char *key;
void *data;
char *key;
void *data;
@@
-1263,7
+1266,6
@@
XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
SIZEOFKEY);
head = xbt_dict_new();
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
SIZEOFKEY);
head = xbt_dict_new();
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
- nb = 0;
for (j = 0; j < 1000; j++) {
char *data = NULL;
key = xbt_malloc(SIZEOFKEY);
for (j = 0; j < 1000; j++) {
char *data = NULL;
key = xbt_malloc(SIZEOFKEY);