X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c8b828daeec8e27cec7131eeb37c206d7f581f1a..4feef0a31a4bfb0b073402109bfbb016cb9bc60d:/testsuite/xbt/graphxml_usage.c diff --git a/testsuite/xbt/graphxml_usage.c b/testsuite/xbt/graphxml_usage.c index b7be207336..f0e63f92cc 100644 --- a/testsuite/xbt/graphxml_usage.c +++ b/testsuite/xbt/graphxml_usage.c @@ -6,6 +6,15 @@ /* 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. */ +#ifdef __BORLANDC__ + #pragma hdrstop + #endif + +#include + +#ifdef _MSC_VER +#define snprintf _snprintf +#endif #include "xbt/module.h" #include "xbt/sysdep.h" @@ -15,12 +24,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to graphxml test"); + static void *node_label_and_data(xbt_node_t node, const char *label, const char *data) { char *lbl = xbt_strdup(label); return lbl; } +#define free_label free static const char *node_name(xbt_node_t n) { @@ -30,15 +41,15 @@ static const char *node_name(xbt_node_t n) void test(char *graph_file); void test(char *graph_file) { - int test_node_deletion = 1; - int test_edge_deletion = 1; + int test_node_deletion = 0; + int test_edge_deletion = 0; int test_export_xml = 1; int test_export_dot = 1; int test_export_length = 1; int test_shortest_paths = 1; int test_topo_sort = 1; - int i, j; + unsigned long i, j; unsigned long n; xbt_dynar_t edges = NULL; @@ -65,7 +76,7 @@ void test(char *graph_file) INFO0("---- Dumping Edge lengths ----"); adj = xbt_graph_get_length_matrix(graph); - buf = calloc(n * 20, sizeof(char)); + buf = xbt_new0(char,n * 20); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { sprintf(buf + strlen(buf), "%le\t", adj[i * n + j]); @@ -83,7 +94,7 @@ void test(char *graph_file) INFO0("---- Testing Shortest Paths ----"); route = xbt_graph_shortest_paths(graph); - buf = calloc(n * 40, sizeof(char)); + buf = xbt_new0(char,n * 40); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (route[i * n + j]) @@ -104,7 +115,7 @@ void test(char *graph_file) sorted = xbt_graph_topo_sort(graph); for (i = 0; i < n; i++) { if (sorted[i]) { - INFO3("sorted[%d] = %s (%p)", i, node_name(sorted[i]), sorted[i]); + INFO3("sorted[%lu] = %s (%p)", i, node_name(sorted[i]), sorted[i]); } } free(sorted); @@ -121,7 +132,7 @@ void test(char *graph_file) while (xbt_dynar_length(nodes)) xbt_graph_free_node(graph, *((xbt_node_t *) xbt_dynar_get_ptr(nodes, 0)), - free, NULL); + free_label, NULL); INFO2("After Node deletion: %lu nodes, %lu edges", xbt_dynar_length(nodes), xbt_dynar_length(edges)); } @@ -142,9 +153,13 @@ void test(char *graph_file) xbt_dynar_length(nodes), xbt_dynar_length(edges)); } - xbt_graph_free_graph(graph, NULL, NULL, NULL); + xbt_graph_free_graph(graph, free_label, NULL, NULL); } +#ifdef __BORLANDC__ +#pragma argsused +#endif + int main(int argc, char **argv) { xbt_init(&argc, argv); if (argc == 1) {