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
Removes the gras_config.h inclusion, adds the portable.h inclusion for win32 portability.
[simgrid.git]
/
src
/
xbt
/
dict.c
diff --git
a/src/xbt/dict.c
b/src/xbt/dict.c
index
a51a2ab
..
227347b
100644
(file)
--- a/
src/xbt/dict.c
+++ b/
src/xbt/dict.c
@@
-368,6
+368,10
@@
void xbt_dict_reset(xbt_dict_t dict) {
int i;
xbt_dictelm_t current, previous = NULL;
int i;
xbt_dictelm_t current, previous = NULL;
+
+ if (dict->count == 0)
+ return;
+
for (i = 0; i < dict->table_size; i++) {
current = dict->table[i];
while (current != NULL) {
for (i = 0; i < dict->table_size; i++) {
current = dict->table[i];
while (current != NULL) {
@@
-567,8
+571,20
@@
char *data;
XBT_TEST_UNIT("basic",test_dict_basic,"Basic usage: change, retrieve, traverse"){
XBT_TEST_UNIT("basic",test_dict_basic,"Basic usage: change, retrieve, traverse"){
- xbt_test_add0("Traversal the empty dictionnary");
+ xbt_test_add0("Traversal the null dictionnary");
+ traverse(head);
+
+ xbt_test_add0("Traversal and search the empty dictionnary");
+ head = xbt_dict_new();
traverse(head);
traverse(head);
+ TRY {
+ debuged_remove(head,"12346");
+ } CATCH(e) {
+ if (e.category != not_found_error)
+ xbt_test_exception(e);
+ xbt_ex_free(e);
+ }
+ xbt_dict_free(&head);
xbt_test_add0("Traverse the full dictionnary");
fill(&head);
xbt_test_add0("Traverse the full dictionnary");
fill(&head);
@@
-744,7
+760,7
@@
XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){
for (i=0;i<10;i++) {
head=xbt_dict_new();
for (i=0;i<10;i++) {
head=xbt_dict_new();
- /
/ if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
+ /
* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
nb=0;
for (j=0;j<1000;j++) {
key=xbt_malloc(SIZEOFKEY);
nb=0;
for (j=0;j<1000;j++) {
key=xbt_malloc(SIZEOFKEY);
@@
-767,7
+783,7
@@
XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){
head=xbt_dict_new();
xbt_test_add1("Fill %d elements, with keys being the number of element",NB_ELM);
for (j=0;j<NB_ELM;j++) {
head=xbt_dict_new();
xbt_test_add1("Fill %d elements, with keys being the number of element",NB_ELM);
for (j=0;j<NB_ELM;j++) {
- /
/ if (!(j%1000)) { printf("."); fflush(stdout); }
+ /
* if (!(j%1000)) { printf("."); fflush(stdout); } */
key = xbt_malloc(10);
key = xbt_malloc(10);
@@
-782,7
+798,7
@@
XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){
xbt_test_add1("Search my %d elements 20 times",NB_ELM);
key=xbt_malloc(10);
for (i=0;i<20;i++) {
xbt_test_add1("Search my %d elements 20 times",NB_ELM);
key=xbt_malloc(10);
for (i=0;i<20;i++) {
- /
/ if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
+ /
* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
for (j=0;j<NB_ELM;j++) {
sprintf(key,"%d",j);
for (j=0;j<NB_ELM;j++) {
sprintf(key,"%d",j);
@@
-796,7
+812,7
@@
XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){
xbt_test_add1("Remove my %d elements",NB_ELM);
key=xbt_malloc(10);
for (j=0;j<NB_ELM;j++) {
xbt_test_add1("Remove my %d elements",NB_ELM);
key=xbt_malloc(10);
for (j=0;j<NB_ELM;j++) {
- /
/if (!(j%10000)) printf("."); fflush(stdout);
+ /
* if (!(j%10000)) printf("."); fflush(stdout); */
sprintf(key,"%d",j);
xbt_dict_remove(head,key);
sprintf(key,"%d",j);
xbt_dict_remove(head,key);