r2016 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Sep 25 08:51:04 CEST 2007


Author: phk
Date: 2007-09-25 08:51:04 +0200 (Tue, 25 Sep 2007)
New Revision: 2016

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
Log:
When we take the difference between two pointers, the result is technically
signed.  pdiff() makes sure we never get a negative value.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-09-25 06:46:57 UTC (rev 2015)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-09-25 06:51:04 UTC (rev 2016)
@@ -587,3 +587,17 @@
 		    __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));
+}




More information about the varnish-commit mailing list