aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-07-23 05:32:35 +0000
committerNick Mathewson <nickm@torproject.org>2006-07-23 05:32:35 +0000
commit35960e11620d70c3ea48cac1d17cca9f02eabfbe (patch)
tree99919c66f38a3316d5633587d6faca7181208664 /src/common/util.h
parent1c266c33525f817cd6a1a55be1e83b0cd6eedae6 (diff)
downloadtor-35960e11620d70c3ea48cac1d17cca9f02eabfbe.tar.gz
tor-35960e11620d70c3ea48cac1d17cca9f02eabfbe.zip
Add a mem_is_zero function (I think we will need this) and a STRUCT_OFFSET macro (we already need this).
svn:r6810
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h
index b61b399dec..bc21d2051f 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -88,6 +88,10 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
#define tor_strndup(s, n) _tor_strndup(s, n DMALLOC_ARGS)
#define tor_memdup(s, n) _tor_memdup(s, n DMALLOC_ARGS)
+/** Return the offset of <b>member</b> within the type <b>tp</b>, in bytes */
+#define STRUCT_OFFSET(tp, member) \
+ ((off_t) (((char*)&((tp*)0)->member)-(char*)0))
+
/* String manipulation */
#define HEX_CHARACTERS "0123456789ABCDEFabcdef"
void tor_strlower(char *s);
@@ -114,6 +118,7 @@ const char *hex_str(const char *from, size_t fromlen);
const char *eat_whitespace(const char *s);
const char *eat_whitespace_no_nl(const char *s);
const char *find_whitespace(const char *s);
+int tor_mem_is_zero(const char *mem, size_t len);
int tor_digest_is_zero(const char *digest);
char *esc_for_log(const char *string);
const char *escaped(const char *string);