diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-10 11:22:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-10 11:22:32 +0000 |
commit | 15e4e5ef56c35935b57f2b1efc40548c54234d3e (patch) | |
tree | df43f1d6d61317915bc7a78a1f5de208e7a89cb4 /src/include | |
parent | 52e04dad6eab39408a35da45462c2ddf8a2f6a10 (diff) | |
download | gnunet-15e4e5ef56c35935b57f2b1efc40548c54234d3e.tar.gz gnunet-15e4e5ef56c35935b57f2b1efc40548c54234d3e.zip |
strndup
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_common.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 503fda5c1..7e4f82ad4 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -392,7 +392,7 @@ unsigned long long GNUNET_htonll (unsigned long long n); | |||
392 | * allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) instead of GNUNET_free. | 392 | * allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) instead of GNUNET_free. |
393 | * | 393 | * |
394 | * @param ptr location where to free the memory. ptr must have | 394 | * @param ptr location where to free the memory. ptr must have |
395 | * been returned by GNUNET_strdup, GNUNET_malloc or GNUNET_array_grow earlier. | 395 | * been returned by GNUNET_strdup, GNUNET_strndup, GNUNET_malloc or GNUNET_array_grow earlier. |
396 | */ | 396 | */ |
397 | #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) | 397 | #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) |
398 | 398 | ||
@@ -414,6 +414,16 @@ unsigned long long GNUNET_htonll (unsigned long long n); | |||
414 | #define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__) | 414 | #define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__) |
415 | 415 | ||
416 | /** | 416 | /** |
417 | * Wrapper around GNUNET_strndup. Makes a partial copy of the string | ||
418 | * pointed to by a. | ||
419 | * | ||
420 | * @param a pointer to a string | ||
421 | * @param length of the string to duplicate | ||
422 | * @return a partial copy of the string including zero-termination | ||
423 | */ | ||
424 | #define GNUNET_strndup(a,b) GNUNET_xstrndup_(a,b,__FILE__,__LINE__) | ||
425 | |||
426 | /** | ||
417 | * Grow a well-typed (!) array. This is a convenience | 427 | * Grow a well-typed (!) array. This is a convenience |
418 | * method to grow a vector <tt>arr</tt> of size <tt>size</tt> | 428 | * method to grow a vector <tt>arr</tt> of size <tt>size</tt> |
419 | * to the new (target) size <tt>tsize</tt>. | 429 | * to the new (target) size <tt>tsize</tt>. |
@@ -552,6 +562,16 @@ void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | |||
552 | char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | 562 | char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); |
553 | 563 | ||
554 | /** | 564 | /** |
565 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the GNUNET_strndup macro. | ||
566 | * @param str string to duplicate | ||
567 | * @param len lenght of the string to duplicate | ||
568 | * @param filename where is this call being made (for debugging) | ||
569 | * @param linenumber line where this call is being made (for debugging) | ||
570 | * @return the duplicated string | ||
571 | */ | ||
572 | char *GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, int linenumber); | ||
573 | |||
574 | /** | ||
555 | * Grow an array, the new elements are zeroed out. | 575 | * Grow an array, the new elements are zeroed out. |
556 | * Grows old by (*oldCount-newCount)*elementSize | 576 | * Grows old by (*oldCount-newCount)*elementSize |
557 | * bytes and sets *oldCount to newCount. | 577 | * bytes and sets *oldCount to newCount. |