diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-04-17 10:45:45 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-04-17 10:45:45 -0400 |
commit | 42731f69efc1f7b0614a33cd6ea7a70903bfc98b (patch) | |
tree | 3b5d5e5eedb704f116d26367546c002ebf02d0ca /src/common/util.c | |
parent | a6545d6335cd7829cdc9c0d7ce2e61b775bcca1d (diff) | |
parent | 0cf2c01dbd9b86d396a55186e0656db33c7929d8 (diff) | |
download | tor-42731f69efc1f7b0614a33cd6ea7a70903bfc98b.tar.gz tor-42731f69efc1f7b0614a33cd6ea7a70903bfc98b.zip |
Merge branch 'bug8037_squashed' into maint-0.2.4
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 2f1bc6171b..db160fdf0a 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -281,6 +281,20 @@ tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS) return dup; } +/** As tor_memdup(), but add an extra 0 byte at the end of the resulting + * memory. */ +void * +tor_memdup_nulterm(const void *mem, size_t len DMALLOC_PARAMS) +{ + char *dup; + tor_assert(len < SIZE_T_CEILING+1); + tor_assert(mem); + dup = tor_malloc_(len+1 DMALLOC_FN_ARGS); + memcpy(dup, mem, len); + dup[len] = '\0'; + return dup; +} + /** Helper for places that need to take a function pointer to the right * spelling of "free()". */ void |