diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-14 23:43:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-14 23:43:53 +0000 |
commit | 0c7015a6d8d2b3bf021c216b24d7062cd7375a71 (patch) | |
tree | 18bddea280e5e85d09389e9275c5efd15f17c840 /src/include/gnunet_common.h | |
parent | ca173048a26a418866163d14c9159b9ad712644b (diff) | |
download | gnunet-0c7015a6d8d2b3bf021c216b24d7062cd7375a71.tar.gz gnunet-0c7015a6d8d2b3bf021c216b24d7062cd7375a71.zip |
-playing with doxygen groups
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index ab0876ef9..4552e860e 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2006, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2006-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
7 | by the Free Software Foundation; either version 2, or (at your | 7 | by the Free Software Foundation; either version 3, or (at your |
8 | option) any later version. | 8 | option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
@@ -26,6 +26,9 @@ | |||
26 | * | 26 | * |
27 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
28 | * @author Nils Durner | 28 | * @author Nils Durner |
29 | * | ||
30 | * @defgroup logging Logging | ||
31 | * @defgroup memory Memory management | ||
29 | */ | 32 | */ |
30 | #ifndef GNUNET_COMMON_H | 33 | #ifndef GNUNET_COMMON_H |
31 | #define GNUNET_COMMON_H | 34 | #define GNUNET_COMMON_H |
@@ -104,6 +107,7 @@ extern "C" | |||
104 | #endif | 107 | #endif |
105 | 108 | ||
106 | /** | 109 | /** |
110 | * @ingroup logging | ||
107 | * define GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source | 111 | * define GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source |
108 | * tree where gnunet_config.h is unavailable | 112 | * tree where gnunet_config.h is unavailable |
109 | */ | 113 | */ |
@@ -288,6 +292,7 @@ typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename); | |||
288 | /* ****************************** logging ***************************** */ | 292 | /* ****************************** logging ***************************** */ |
289 | 293 | ||
290 | /** | 294 | /** |
295 | * @ingroup logging | ||
291 | * Types of errors. | 296 | * Types of errors. |
292 | */ | 297 | */ |
293 | enum GNUNET_ErrorType | 298 | enum GNUNET_ErrorType |
@@ -304,6 +309,7 @@ enum GNUNET_ErrorType | |||
304 | 309 | ||
305 | 310 | ||
306 | /** | 311 | /** |
312 | * @ingroup logging | ||
307 | * User-defined handler for log messages. | 313 | * User-defined handler for log messages. |
308 | * | 314 | * |
309 | * @param cls closure | 315 | * @param cls closure |
@@ -318,6 +324,7 @@ typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind, | |||
318 | 324 | ||
319 | 325 | ||
320 | /** | 326 | /** |
327 | * @ingroup logging | ||
321 | * Get the number of log calls that are going to be skipped | 328 | * Get the number of log calls that are going to be skipped |
322 | * | 329 | * |
323 | * @return number of log calls to be ignored | 330 | * @return number of log calls to be ignored |
@@ -333,6 +340,7 @@ GNUNET_get_log_call_status (int caller_level, const char *comp, | |||
333 | 340 | ||
334 | 341 | ||
335 | /** | 342 | /** |
343 | * @ingroup logging | ||
336 | * Main log function. | 344 | * Main log function. |
337 | * | 345 | * |
338 | * @param kind how serious is the error? | 346 | * @param kind how serious is the error? |
@@ -364,7 +372,9 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...); | |||
364 | #define GNUNET_LOG_CALL_STATUS -1 | 372 | #define GNUNET_LOG_CALL_STATUS -1 |
365 | #endif | 373 | #endif |
366 | 374 | ||
375 | |||
367 | /** | 376 | /** |
377 | * @ingroup logging | ||
368 | * Log function that specifies an alternative component. | 378 | * Log function that specifies an alternative component. |
369 | * This function should be used by plugins. | 379 | * This function should be used by plugins. |
370 | * | 380 | * |
@@ -410,6 +420,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp, | |||
410 | 420 | ||
411 | 421 | ||
412 | /** | 422 | /** |
423 | * @ingroup logging | ||
413 | * Log error message about missing configuration option. | 424 | * Log error message about missing configuration option. |
414 | * | 425 | * |
415 | * @param kind log level | 426 | * @param kind log level |
@@ -423,6 +434,7 @@ GNUNET_log_config_missing (enum GNUNET_ErrorType kind, | |||
423 | 434 | ||
424 | 435 | ||
425 | /** | 436 | /** |
437 | * @ingroup logging | ||
426 | * Log error message about invalid configuration option value. | 438 | * Log error message about invalid configuration option value. |
427 | * | 439 | * |
428 | * @param kind log level | 440 | * @param kind log level |
@@ -438,13 +450,16 @@ GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, | |||
438 | 450 | ||
439 | 451 | ||
440 | /** | 452 | /** |
453 | * @ingroup logging | ||
441 | * Abort the process, generate a core dump if possible. | 454 | * Abort the process, generate a core dump if possible. |
442 | */ | 455 | */ |
443 | void | 456 | void |
444 | GNUNET_abort (void) GNUNET_NORETURN; | 457 | GNUNET_abort (void) GNUNET_NORETURN; |
445 | 458 | ||
459 | |||
446 | /** | 460 | /** |
447 | * Ignore the next n calls to the log function. | 461 | * @ingroup logging |
462 | * Ignore the next @a n calls to the log function. | ||
448 | * | 463 | * |
449 | * @param n number of log calls to ignore (could be negative) | 464 | * @param n number of log calls to ignore (could be negative) |
450 | * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero | 465 | * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero |
@@ -454,6 +469,7 @@ GNUNET_log_skip (int n, int check_reset); | |||
454 | 469 | ||
455 | 470 | ||
456 | /** | 471 | /** |
472 | * @ingroup logging | ||
457 | * Setup logging. | 473 | * Setup logging. |
458 | * | 474 | * |
459 | * @param comp default component to use | 475 | * @param comp default component to use |
@@ -466,6 +482,7 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); | |||
466 | 482 | ||
467 | 483 | ||
468 | /** | 484 | /** |
485 | * @ingroup logging | ||
469 | * Add a custom logger. | 486 | * Add a custom logger. |
470 | * | 487 | * |
471 | * @param logger log function | 488 | * @param logger log function |
@@ -476,6 +493,7 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); | |||
476 | 493 | ||
477 | 494 | ||
478 | /** | 495 | /** |
496 | * @ingroup logging | ||
479 | * Remove a custom logger. | 497 | * Remove a custom logger. |
480 | * | 498 | * |
481 | * @param logger log function | 499 | * @param logger log function |
@@ -486,6 +504,7 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); | |||
486 | 504 | ||
487 | 505 | ||
488 | /** | 506 | /** |
507 | * @ingroup logging | ||
489 | * Convert a short hash value to a string (for printing debug messages). | 508 | * Convert a short hash value to a string (for printing debug messages). |
490 | * This is one of the very few calls in the entire API that is | 509 | * This is one of the very few calls in the entire API that is |
491 | * NOT reentrant! | 510 | * NOT reentrant! |
@@ -498,6 +517,7 @@ GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc); | |||
498 | 517 | ||
499 | 518 | ||
500 | /** | 519 | /** |
520 | * @ingroup logging | ||
501 | * Convert a short hash value to a string (for printing debug messages). | 521 | * Convert a short hash value to a string (for printing debug messages). |
502 | * This prints all 104 characters of a hashcode! | 522 | * This prints all 104 characters of a hashcode! |
503 | * This is one of the very few calls in the entire API that is | 523 | * This is one of the very few calls in the entire API that is |
@@ -511,6 +531,7 @@ GNUNET_short_h2s_full (const struct GNUNET_CRYPTO_ShortHashCode * hc); | |||
511 | 531 | ||
512 | 532 | ||
513 | /** | 533 | /** |
534 | * @ingroup logging | ||
514 | * Convert a hash value to a string (for printing debug messages). | 535 | * Convert a hash value to a string (for printing debug messages). |
515 | * This is one of the very few calls in the entire API that is | 536 | * This is one of the very few calls in the entire API that is |
516 | * NOT reentrant! | 537 | * NOT reentrant! |
@@ -523,6 +544,7 @@ GNUNET_h2s (const struct GNUNET_HashCode * hc); | |||
523 | 544 | ||
524 | 545 | ||
525 | /** | 546 | /** |
547 | * @ingroup logging | ||
526 | * Convert a hash value to a string (for printing debug messages). | 548 | * Convert a hash value to a string (for printing debug messages). |
527 | * This prints all 104 characters of a hashcode! | 549 | * This prints all 104 characters of a hashcode! |
528 | * This is one of the very few calls in the entire API that is | 550 | * This is one of the very few calls in the entire API that is |
@@ -536,6 +558,7 @@ GNUNET_h2s_full (const struct GNUNET_HashCode * hc); | |||
536 | 558 | ||
537 | 559 | ||
538 | /** | 560 | /** |
561 | * @ingroup logging | ||
539 | * Convert a peer identity to a string (for printing debug messages). | 562 | * Convert a peer identity to a string (for printing debug messages). |
540 | * This is one of the very few calls in the entire API that is | 563 | * This is one of the very few calls in the entire API that is |
541 | * NOT reentrant! | 564 | * NOT reentrant! |
@@ -547,7 +570,9 @@ GNUNET_h2s_full (const struct GNUNET_HashCode * hc); | |||
547 | const char * | 570 | const char * |
548 | GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); | 571 | GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); |
549 | 572 | ||
573 | |||
550 | /** | 574 | /** |
575 | * @ingroup logging | ||
551 | * Convert a peer identity to a string (for printing debug messages). | 576 | * Convert a peer identity to a string (for printing debug messages). |
552 | * This is one of the very few calls in the entire API that is | 577 | * This is one of the very few calls in the entire API that is |
553 | * NOT reentrant! | 578 | * NOT reentrant! |
@@ -559,7 +584,9 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); | |||
559 | const char * | 584 | const char * |
560 | GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); | 585 | GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); |
561 | 586 | ||
587 | |||
562 | /** | 588 | /** |
589 | * @ingroup logging | ||
563 | * Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string | 590 | * Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string |
564 | * (for printing debug messages). This is one of the very few calls | 591 | * (for printing debug messages). This is one of the very few calls |
565 | * in the entire API that is NOT reentrant! | 592 | * in the entire API that is NOT reentrant! |
@@ -572,7 +599,9 @@ GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); | |||
572 | const char * | 599 | const char * |
573 | GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); | 600 | GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); |
574 | 601 | ||
602 | |||
575 | /** | 603 | /** |
604 | * @ingroup logging | ||
576 | * Convert error type to string. | 605 | * Convert error type to string. |
577 | * | 606 | * |
578 | * @param kind type to convert | 607 | * @param kind type to convert |
@@ -583,22 +612,29 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
583 | 612 | ||
584 | 613 | ||
585 | /** | 614 | /** |
615 | * @ingroup logging | ||
586 | * Use this for fatal errors that cannot be handled | 616 | * Use this for fatal errors that cannot be handled |
587 | */ | 617 | */ |
588 | #define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_abort(); } } while(0) | 618 | #define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_abort(); } } while(0) |
589 | 619 | ||
620 | |||
590 | /** | 621 | /** |
622 | * @ingroup logging | ||
591 | * Use this for fatal errors that cannot be handled | 623 | * Use this for fatal errors that cannot be handled |
592 | */ | 624 | */ |
593 | #define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort(); } } while(0) | 625 | #define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort(); } } while(0) |
594 | 626 | ||
627 | |||
595 | /** | 628 | /** |
629 | * @ingroup logging | ||
596 | * Use this for internal assertion violations that are | 630 | * Use this for internal assertion violations that are |
597 | * not fatal (can be handled) but should not occur. | 631 | * not fatal (can be handled) but should not occur. |
598 | */ | 632 | */ |
599 | #define GNUNET_break(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); } } while(0) | 633 | #define GNUNET_break(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); } } while(0) |
600 | 634 | ||
635 | |||
601 | /** | 636 | /** |
637 | * @ingroup logging | ||
602 | * Use this for assertion violations caused by other | 638 | * Use this for assertion violations caused by other |
603 | * peers (i.e. protocol violations). We do not want to | 639 | * peers (i.e. protocol violations). We do not want to |
604 | * confuse end-users (say, some other peer runs an | 640 | * confuse end-users (say, some other peer runs an |
@@ -608,28 +644,36 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
608 | */ | 644 | */ |
609 | #define GNUNET_break_op(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("External protocol violation detected at %s:%d.\n"), __FILE__, __LINE__); } } while(0) | 645 | #define GNUNET_break_op(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("External protocol violation detected at %s:%d.\n"), __FILE__, __LINE__); } } while(0) |
610 | 646 | ||
647 | |||
611 | /** | 648 | /** |
649 | * @ingroup logging | ||
612 | * Log an error message at log-level 'level' that indicates | 650 | * Log an error message at log-level 'level' that indicates |
613 | * a failure of the command 'cmd' with the message given | 651 | * a failure of the command 'cmd' with the message given |
614 | * by strerror(errno). | 652 | * by strerror(errno). |
615 | */ | 653 | */ |
616 | #define GNUNET_log_strerror(level, cmd) do { GNUNET_log(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0) | 654 | #define GNUNET_log_strerror(level, cmd) do { GNUNET_log(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0) |
617 | 655 | ||
656 | |||
618 | /** | 657 | /** |
658 | * @ingroup logging | ||
619 | * Log an error message at log-level 'level' that indicates | 659 | * Log an error message at log-level 'level' that indicates |
620 | * a failure of the command 'cmd' with the message given | 660 | * a failure of the command 'cmd' with the message given |
621 | * by strerror(errno). | 661 | * by strerror(errno). |
622 | */ | 662 | */ |
623 | #define GNUNET_log_from_strerror(level, component, cmd) do { GNUNET_log_from (level, component, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0) | 663 | #define GNUNET_log_from_strerror(level, component, cmd) do { GNUNET_log_from (level, component, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0) |
624 | 664 | ||
665 | |||
625 | /** | 666 | /** |
667 | * @ingroup logging | ||
626 | * Log an error message at log-level 'level' that indicates | 668 | * Log an error message at log-level 'level' that indicates |
627 | * a failure of the command 'cmd' with the message given | 669 | * a failure of the command 'cmd' with the message given |
628 | * by strerror(errno). | 670 | * by strerror(errno). |
629 | */ | 671 | */ |
630 | #define GNUNET_log_strerror_file(level, cmd, filename) do { GNUNET_log(level, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename,__FILE__, __LINE__, STRERROR(errno)); } while(0) | 672 | #define GNUNET_log_strerror_file(level, cmd, filename) do { GNUNET_log(level, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename,__FILE__, __LINE__, STRERROR(errno)); } while(0) |
631 | 673 | ||
674 | |||
632 | /** | 675 | /** |
676 | * @ingroup logging | ||
633 | * Log an error message at log-level 'level' that indicates | 677 | * Log an error message at log-level 'level' that indicates |
634 | * a failure of the command 'cmd' with the message given | 678 | * a failure of the command 'cmd' with the message given |
635 | * by strerror(errno). | 679 | * by strerror(errno). |
@@ -673,11 +717,13 @@ GNUNET_ntoh_double (double d); | |||
673 | /* ************************* allocation functions ****************** */ | 717 | /* ************************* allocation functions ****************** */ |
674 | 718 | ||
675 | /** | 719 | /** |
720 | * @ingroup memory | ||
676 | * Maximum allocation with GNUNET_malloc macro. | 721 | * Maximum allocation with GNUNET_malloc macro. |
677 | */ | 722 | */ |
678 | #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40) | 723 | #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40) |
679 | 724 | ||
680 | /** | 725 | /** |
726 | * @ingroup memory | ||
681 | * Allocate a struct or union of the given 'type'. | 727 | * Allocate a struct or union of the given 'type'. |
682 | * Wrapper around GNUNET_malloc that returns a pointer | 728 | * Wrapper around GNUNET_malloc that returns a pointer |
683 | * to the newly created object of the correct type. | 729 | * to the newly created object of the correct type. |
@@ -687,6 +733,7 @@ GNUNET_ntoh_double (double d); | |||
687 | #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type)) | 733 | #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type)) |
688 | 734 | ||
689 | /** | 735 | /** |
736 | * @ingroup memory | ||
690 | * Wrapper around malloc. Allocates size bytes of memory. | 737 | * Wrapper around malloc. Allocates size bytes of memory. |
691 | * The memory will be zero'ed out. | 738 | * The memory will be zero'ed out. |
692 | * | 739 | * |
@@ -697,6 +744,7 @@ GNUNET_ntoh_double (double d); | |||
697 | #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) | 744 | #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) |
698 | 745 | ||
699 | /** | 746 | /** |
747 | * @ingroup memory | ||
700 | * Allocate and initialize a block of memory. | 748 | * Allocate and initialize a block of memory. |
701 | * | 749 | * |
702 | * @param buf data to initalize the block with | 750 | * @param buf data to initalize the block with |
@@ -706,6 +754,7 @@ GNUNET_ntoh_double (double d); | |||
706 | #define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__) | 754 | #define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__) |
707 | 755 | ||
708 | /** | 756 | /** |
757 | * @ingroup memory | ||
709 | * Wrapper around malloc. Allocates size bytes of memory. | 758 | * Wrapper around malloc. Allocates size bytes of memory. |
710 | * The memory will be zero'ed out. | 759 | * The memory will be zero'ed out. |
711 | * | 760 | * |
@@ -715,6 +764,7 @@ GNUNET_ntoh_double (double d); | |||
715 | #define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__) | 764 | #define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__) |
716 | 765 | ||
717 | /** | 766 | /** |
767 | * @ingroup memory | ||
718 | * Wrapper around realloc. Rellocates size bytes of memory. | 768 | * Wrapper around realloc. Rellocates size bytes of memory. |
719 | * | 769 | * |
720 | * @param ptr the pointer to reallocate | 770 | * @param ptr the pointer to reallocate |
@@ -724,6 +774,7 @@ GNUNET_ntoh_double (double d); | |||
724 | #define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__) | 774 | #define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__) |
725 | 775 | ||
726 | /** | 776 | /** |
777 | * @ingroup memory | ||
727 | * Wrapper around free. Frees the memory referred to by ptr. | 778 | * Wrapper around free. Frees the memory referred to by ptr. |
728 | * Note that is is generally better to free memory that was | 779 | * Note that is is generally better to free memory that was |
729 | * allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) instead of GNUNET_free. | 780 | * allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) instead of GNUNET_free. |
@@ -734,6 +785,7 @@ GNUNET_ntoh_double (double d); | |||
734 | #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) | 785 | #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) |
735 | 786 | ||
736 | /** | 787 | /** |
788 | * @ingroup memory | ||
737 | * Free the memory pointed to by ptr if ptr is not NULL. | 789 | * Free the memory pointed to by ptr if ptr is not NULL. |
738 | * Equivalent to if (ptr!=null)GNUNET_free(ptr). | 790 | * Equivalent to if (ptr!=null)GNUNET_free(ptr). |
739 | * | 791 | * |
@@ -742,6 +794,7 @@ GNUNET_ntoh_double (double d); | |||
742 | #define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NULL) { GNUNET_free(__x__); } } while(0) | 794 | #define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NULL) { GNUNET_free(__x__); } } while(0) |
743 | 795 | ||
744 | /** | 796 | /** |
797 | * @ingroup memory | ||
745 | * Wrapper around GNUNET_strdup. Makes a copy of the zero-terminated string | 798 | * Wrapper around GNUNET_strdup. Makes a copy of the zero-terminated string |
746 | * pointed to by a. | 799 | * pointed to by a. |
747 | * | 800 | * |
@@ -751,6 +804,7 @@ GNUNET_ntoh_double (double d); | |||
751 | #define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__) | 804 | #define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__) |
752 | 805 | ||
753 | /** | 806 | /** |
807 | * @ingroup memory | ||
754 | * Wrapper around GNUNET_strndup. Makes a partial copy of the string | 808 | * Wrapper around GNUNET_strndup. Makes a partial copy of the string |
755 | * pointed to by a. | 809 | * pointed to by a. |
756 | * | 810 | * |
@@ -761,6 +815,7 @@ GNUNET_ntoh_double (double d); | |||
761 | #define GNUNET_strndup(a,length) GNUNET_xstrndup_(a,length,__FILE__,__LINE__) | 815 | #define GNUNET_strndup(a,length) GNUNET_xstrndup_(a,length,__FILE__,__LINE__) |
762 | 816 | ||
763 | /** | 817 | /** |
818 | * @ingroup memory | ||
764 | * Grow a well-typed (!) array. This is a convenience | 819 | * Grow a well-typed (!) array. This is a convenience |
765 | * method to grow a vector <tt>arr</tt> of size <tt>size</tt> | 820 | * method to grow a vector <tt>arr</tt> of size <tt>size</tt> |
766 | * to the new (target) size <tt>tsize</tt>. | 821 | * to the new (target) size <tt>tsize</tt>. |
@@ -796,12 +851,14 @@ GNUNET_ntoh_double (double d); | |||
796 | #define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&arr, sizeof(arr[0]), &size, tsize, __FILE__, __LINE__) | 851 | #define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&arr, sizeof(arr[0]), &size, tsize, __FILE__, __LINE__) |
797 | 852 | ||
798 | /** | 853 | /** |
854 | * @ingroup memory | ||
799 | * Append an element to a list (growing the | 855 | * Append an element to a list (growing the |
800 | * list by one). | 856 | * list by one). |
801 | */ | 857 | */ |
802 | #define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,size,size+1); arr[size-1] = element; } while(0) | 858 | #define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,size,size+1); arr[size-1] = element; } while(0) |
803 | 859 | ||
804 | /** | 860 | /** |
861 | * @ingroup memory | ||
805 | * Like snprintf, just aborts if the buffer is of insufficient size. | 862 | * Like snprintf, just aborts if the buffer is of insufficient size. |
806 | * | 863 | * |
807 | * @param buf pointer to buffer that is written to | 864 | * @param buf pointer to buffer that is written to |
@@ -815,6 +872,7 @@ GNUNET_snprintf (char *buf, size_t size, const char *format, ...); | |||
815 | 872 | ||
816 | 873 | ||
817 | /** | 874 | /** |
875 | * @ingroup memory | ||
818 | * Like asprintf, just portable. | 876 | * Like asprintf, just portable. |
819 | * | 877 | * |
820 | * @param buf set to a buffer of sufficient size (allocated, caller must free) | 878 | * @param buf set to a buffer of sufficient size (allocated, caller must free) |
@@ -938,6 +996,7 @@ GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, | |||
938 | 996 | ||
939 | 997 | ||
940 | /** | 998 | /** |
999 | * @ingroup memory | ||
941 | * Create a copy of the given message. | 1000 | * Create a copy of the given message. |
942 | * | 1001 | * |
943 | * @param msg message to copy | 1002 | * @param msg message to copy |