aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-02-25 15:58:55 -0500
committerNick Mathewson <nickm@torproject.org>2010-02-25 16:09:10 -0500
commit6fa8dacb97587707156507aa35141e414fc284bb (patch)
treed51c20ce8b0e65a0c17aff72a119c2b2686d1496 /src/common/compat.h
parent8b93dacbcfbca7b4653f7a9b727bdc209aff1e7c (diff)
downloadtor-6fa8dacb97587707156507aa35141e414fc284bb.tar.gz
tor-6fa8dacb97587707156507aa35141e414fc284bb.zip
Add a tor_asprintf() function, and use it in a couple of places.
asprintf() is a GNU extension that some BSDs have picked up: it does a printf into a newly allocated chunk of RAM. Our tor_asprintf() differs from standard asprintf() in that: - Like our other malloc functions, it asserts on OOM. - It works on windows. - It always sets its return-field.
Diffstat (limited to 'src/common/compat.h')
-rw-r--r--src/common/compat.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/compat.h b/src/common/compat.h
index 554ae8919f..f3e30452bd 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -235,6 +235,10 @@ int tor_snprintf(char *str, size_t size, const char *format, ...)
int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
ATTR_NONNULL((1,3));
+int tor_asprintf(char **strp, const char *fmt, ...)
+ CHECK_PRINTF(2,3);
+int tor_vasprintf(char **strp, const char *fmt, va_list args);
+
const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
size_t nlen) ATTR_PURE ATTR_NONNULL((1,3));
static const void *tor_memstr(const void *haystack, size_t hlen,