diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-04-17 06:55:08 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-04-17 06:55:08 +0000 |
commit | 838d0a81c3343432897739d14e2af1a4e5edb7db (patch) | |
tree | 13ce8ca399a18d808bb808b93169a5ce7644f18f /util-internal.h | |
parent | 433e2339ca1605326f35c2d873a42f6d2abe505d (diff) | |
download | libevent-838d0a81c3343432897739d14e2af1a4e5edb7db.tar.gz |
Document many internal functions and pieces of code.
svn:r1181
Diffstat (limited to 'util-internal.h')
-rw-r--r-- | util-internal.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util-internal.h b/util-internal.h index 31f2239f..73f11ae4 100644 --- a/util-internal.h +++ b/util-internal.h @@ -101,6 +101,21 @@ extern const char EVUTIL_TOLOWER_TABLE[]; #define EVUTIL_TOLOWER(c) (EVUTIL_TOLOWER_TABLE[(ev_uint8_t)c]) #define EVUTIL_TOUPPER(c) (EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c]) +/** Helper macro. If we know that a given pointer points to a field in a + structure, return a pointer to the structure itself. Used to implement + our half-baked C OO. Example: + + struct subtype { + int x; + struct supertype common; + int y; + }; + ... + void fn(struct supertype *super) { + struct subtype *sub = EVUTIL_UPCAST(super, struct subtype, common); + ... + } + */ #define EVUTIL_UPCAST(ptr, type, field) \ ((type *)((char*)ptr) - evutil_offsetof(type, field)) |