diff options
author | Julius Bünger <buenger@mytum.de> | 2019-04-11 13:02:18 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2019-04-11 13:03:13 +0200 |
commit | 6fd0634f2e378276c93e84b3d296f43307aae317 (patch) | |
tree | 8e7394c8d67e152dd55c0e79293e45e0c6528c6b /src/rps/rps-test_util.c | |
parent | c457ee81954163e0b7295fbd4a713474b3059abf (diff) | |
download | gnunet-6fd0634f2e378276c93e84b3d296f43307aae317.tar.gz gnunet-6fd0634f2e378276c93e84b3d296f43307aae317.zip |
RPS profiler: Compute probabilities wrt history
Diffstat (limited to 'src/rps/rps-test_util.c')
-rw-r--r-- | src/rps/rps-test_util.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index fcb4f59a0..ab023a7a6 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c | |||
@@ -456,18 +456,29 @@ ensure_folder_exist (void) | |||
456 | 456 | ||
457 | 457 | ||
458 | char * | 458 | char * |
459 | store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, | 459 | store_prefix_file_name (const unsigned int index, |
460 | const char *prefix) | 460 | const char *prefix) |
461 | { | 461 | { |
462 | int len_file_name; | 462 | int len_file_name; |
463 | int out_size; | 463 | int out_size; |
464 | char *file_name; | 464 | char *file_name; |
465 | const char *pid_long; | 465 | char index_str[64]; |
466 | 466 | ||
467 | if (GNUNET_SYSERR == ensure_folder_exist()) return NULL; | 467 | if (GNUNET_SYSERR == ensure_folder_exist()) return NULL; |
468 | pid_long = GNUNET_i2s_full (peer); | 468 | out_size = GNUNET_snprintf (index_str, |
469 | 64, | ||
470 | "%u", | ||
471 | index); | ||
472 | if (64 < out_size || | ||
473 | 0 > out_size) | ||
474 | { | ||
475 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
476 | "Failed to write string to buffer (size: %i, out_size: %i)\n", | ||
477 | 64, | ||
478 | out_size); | ||
479 | } | ||
469 | len_file_name = (strlen (prefix) + | 480 | len_file_name = (strlen (prefix) + |
470 | strlen (pid_long) + | 481 | strlen (index_str) + |
471 | 11) | 482 | 11) |
472 | * sizeof (char); | 483 | * sizeof (char); |
473 | file_name = GNUNET_malloc (len_file_name); | 484 | file_name = GNUNET_malloc (len_file_name); |
@@ -475,7 +486,7 @@ store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, | |||
475 | len_file_name, | 486 | len_file_name, |
476 | "/tmp/rps/%s-%s", | 487 | "/tmp/rps/%s-%s", |
477 | prefix, | 488 | prefix, |
478 | pid_long); | 489 | index_str); |
479 | if (len_file_name < out_size || | 490 | if (len_file_name < out_size || |
480 | 0 > out_size) | 491 | 0 > out_size) |
481 | { | 492 | { |