diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-09-25 22:10:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-09-25 22:10:51 +0000 |
commit | f1b9c5c115139b02cac1cae4f053792e1e5b1ccb (patch) | |
tree | cd9047d73ba498d05f67c7e06ae4bd5ed89511e7 /src/include/gnunet_common.h | |
parent | c2d3d24cd9b4f552d7ca8ad6283f9819c1cfefc7 (diff) | |
download | gnunet-f1b9c5c115139b02cac1cae4f053792e1e5b1ccb.tar.gz gnunet-f1b9c5c115139b02cac1cae4f053792e1e5b1ccb.zip |
improving style and docs
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 614fd3824..402674f48 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2006 Christian Grothoff (and other contributing authors) | 3 | (C) 2006, 2009 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 |
@@ -413,11 +413,23 @@ unsigned long long GNUNET_htonll (unsigned long long n); | |||
413 | 413 | ||
414 | /** | 414 | /** |
415 | * Like snprintf, just aborts if the buffer is of insufficient size. | 415 | * Like snprintf, just aborts if the buffer is of insufficient size. |
416 | * | ||
417 | * @param buf pointer to buffer that is written to | ||
418 | * @param size number of bytes in buf | ||
419 | * @param format format strings | ||
420 | * @param ... data for format string | ||
421 | * @return number of bytes written to buf or negative value on error | ||
416 | */ | 422 | */ |
417 | int GNUNET_snprintf (char *buf, size_t size, const char *format, ...); | 423 | int GNUNET_snprintf (char *buf, size_t size, const char *format, ...); |
418 | 424 | ||
425 | |||
419 | /** | 426 | /** |
420 | * Like asprintf, just portable. | 427 | * Like asprintf, just portable. |
428 | * | ||
429 | * @param buf set to a buffer of sufficient size (allocated, caller must free) | ||
430 | * @param format format string (see printf, fprintf, etc.) | ||
431 | * @param ... data for format string | ||
432 | * @return number of bytes in "*buf" excluding 0-termination | ||
421 | */ | 433 | */ |
422 | int GNUNET_asprintf (char **buf, const char *format, ...); | 434 | int GNUNET_asprintf (char **buf, const char *format, ...); |
423 | 435 | ||
@@ -429,15 +441,26 @@ int GNUNET_asprintf (char **buf, const char *format, ...); | |||
429 | * memory is available. Don't use GNUNET_xmalloc_ directly. Use the | 441 | * memory is available. Don't use GNUNET_xmalloc_ directly. Use the |
430 | * GNUNET_malloc macro. | 442 | * GNUNET_malloc macro. |
431 | * The memory will be zero'ed out. | 443 | * The memory will be zero'ed out. |
444 | * | ||
445 | * @param size number of bytes to allocate | ||
446 | * @param filename where is this call being made (for debugging) | ||
447 | * @param linenumber line where this call is being made (for debugging) | ||
448 | * @return allocated memory, never NULL | ||
432 | */ | 449 | */ |
433 | void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | 450 | void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); |
434 | 451 | ||
452 | |||
435 | /** | 453 | /** |
436 | * Allocate memory. This function does not check if the | 454 | * Allocate memory. This function does not check if the |
437 | * allocation request is within reasonable bounds, allowing | 455 | * allocation request is within reasonable bounds, allowing |
438 | * allocations larger than 40 MB. If you don't expect the | 456 | * allocations larger than 40 MB. If you don't expect the |
439 | * possibility of very large allocations, use GNUNET_malloc instead. | 457 | * possibility of very large allocations, use GNUNET_malloc instead. |
440 | * The memory will be zero'ed out. | 458 | * The memory will be zero'ed out. |
459 | * | ||
460 | * @param size number of bytes to allocate | ||
461 | * @param filename where is this call being made (for debugging) | ||
462 | * @param linenumber line where this call is being made (for debugging) | ||
463 | * @return allocated memory, never NULL | ||
441 | */ | 464 | */ |
442 | void *GNUNET_xmalloc_unchecked_ (size_t size, | 465 | void *GNUNET_xmalloc_unchecked_ (size_t size, |
443 | const char *filename, int linenumber); | 466 | const char *filename, int linenumber); |
@@ -453,12 +476,20 @@ void *GNUNET_xrealloc_ (void *ptr, | |||
453 | * Free memory. Merely a wrapper for the case that we | 476 | * Free memory. Merely a wrapper for the case that we |
454 | * want to keep track of allocations. Don't use GNUNET_xfree_ | 477 | * want to keep track of allocations. Don't use GNUNET_xfree_ |
455 | * directly. Use the GNUNET_free macro. | 478 | * directly. Use the GNUNET_free macro. |
479 | * | ||
480 | * @param ptr pointer to memory to free | ||
481 | * @param filename where is this call being made (for debugging) | ||
482 | * @param linenumber line where this call is being made (for debugging) | ||
456 | */ | 483 | */ |
457 | void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | 484 | void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); |
458 | 485 | ||
459 | 486 | ||
460 | /** | 487 | /** |
461 | * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro. | 488 | * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro. |
489 | * @param str string to duplicate | ||
490 | * @param filename where is this call being made (for debugging) | ||
491 | * @param linenumber line where this call is being made (for debugging) | ||
492 | * @return the duplicated string | ||
462 | */ | 493 | */ |
463 | char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | 494 | char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); |
464 | 495 | ||
@@ -474,6 +505,8 @@ char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | |||
474 | * @param elementSize the size of the elements of the array | 505 | * @param elementSize the size of the elements of the array |
475 | * @param oldCount address of the number of elements in the *old array | 506 | * @param oldCount address of the number of elements in the *old array |
476 | * @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards) | 507 | * @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards) |
508 | * @param filename where is this call being made (for debugging) | ||
509 | * @param linenumber line where this call is being made (for debugging) | ||
477 | */ | 510 | */ |
478 | void GNUNET_xgrow_ (void **old, | 511 | void GNUNET_xgrow_ (void **old, |
479 | size_t elementSize, | 512 | size_t elementSize, |