Commit b9c64e26 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

When we take the difference between two pointers, the result is technically

signed.  pdiff() makes sure we never get a negative value.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2016 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent fdedf476
......@@ -587,3 +587,17 @@ do { \
__func__, __FILE__, __LINE__); \
} while (0);
#endif
/*
* A normal pointer difference is signed, but we never want a negative value
* so this little tool will make sure we don't get that.
*/
static inline unsigned
pdiff(const void *b, const void *e)
{
assert(b <= e);
return
((unsigned)((const unsigned char *)e - (const unsigned char *)b));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment