diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-11-24 14:23:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-11-24 14:23:32 +0000 |
commit | c6fe079ca7000f7cd1fe6978d891f4d75b9f44ba (patch) | |
tree | b4b96d109a9916392d1c718d7ebaa5c69a84253d /src/include/gnunet_common.h | |
parent | 50c90b76002c2e37e36a98ca0b2f01b1d0e8f84d (diff) | |
download | gnunet-c6fe079ca7000f7cd1fe6978d891f4d75b9f44ba.tar.gz gnunet-c6fe079ca7000f7cd1fe6978d891f4d75b9f44ba.zip |
memdup
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index badb52880..dddee068a 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -354,6 +354,15 @@ unsigned long long GNUNET_htonll (unsigned long long n); | |||
354 | #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) | 354 | #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) |
355 | 355 | ||
356 | /** | 356 | /** |
357 | * Allocate and initialize a block of memory. | ||
358 | * | ||
359 | * @param buf data to initalize the block with | ||
360 | * @param size the number of bytes in buf (and size of the allocation) | ||
361 | * @return pointer to size bytes of memory, never NULL (!) | ||
362 | */ | ||
363 | #define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__) | ||
364 | |||
365 | /** | ||
357 | * Wrapper around malloc. Allocates size bytes of memory. | 366 | * Wrapper around malloc. Allocates size bytes of memory. |
358 | * The memory will be zero'ed out. | 367 | * The memory will be zero'ed out. |
359 | * | 368 | * |
@@ -478,6 +487,21 @@ int GNUNET_asprintf (char **buf, const char *format, ...); | |||
478 | void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | 487 | void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); |
479 | 488 | ||
480 | 489 | ||
490 | |||
491 | /** | ||
492 | * Allocate and initialize memory. Checks the return value, aborts if no more | ||
493 | * memory is available. Don't use GNUNET_xmemdup_ directly. Use the | ||
494 | * GNUNET_memdup macro. | ||
495 | * | ||
496 | * @param buf buffer to initialize from (must contain size bytes) | ||
497 | * @param size number of bytes to allocate | ||
498 | * @param filename where is this call being made (for debugging) | ||
499 | * @param linenumber line where this call is being made (for debugging) | ||
500 | * @return allocated memory, never NULL | ||
501 | */ | ||
502 | void *GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename, int linenumber); | ||
503 | |||
504 | |||
481 | /** | 505 | /** |
482 | * Allocate memory. This function does not check if the allocation | 506 | * Allocate memory. This function does not check if the allocation |
483 | * request is within reasonable bounds, allowing allocations larger | 507 | * request is within reasonable bounds, allowing allocations larger |