Inspired from the SuSE patch submitted by Christian. This is what I
think should be happening with real ptr maths instead of obsolete
integer math with potential rounding and endian errors.
The whole of this code is 'icky' as the existing comments say. But I'm
not going to touch store APIs to fix it at the current time.
This patch is needed for the stable branches as well if it get the go-ahead.
Amos
--
Please be using
Current Stable Squid 2.7.STABLE9 or 3.1.8
Beta testers wanted for 3.2.0.2
=== modified file 'src/mem_node.cc'
--- src/mem_node.cc 2009-01-21 03:47:47 +0000
+++ src/mem_node.cc 2010-09-06 06:54:29 +0000
@@ -36,19 +36,19 @@
#include "squid.h"
#include "mem_node.h"
-static int makeMemNodeDataOffset();
+static ptrdiff_t makeMemNodeDataOffset();
-static int _mem_node_data_offset = makeMemNodeDataOffset();
+static ptrdiff_t _mem_node_data_offset = makeMemNodeDataOffset();
/*
* Calculate the offset between the start of a mem_node and
* its 'data' member
*/
-static int
+static ptrdiff_t
makeMemNodeDataOffset()
{
mem_node *p = 0L;
- return int(ptrdiff_t(&p->data));
+ return ptrdiff_t(&p->data);
}
/*
@@ -60,7 +60,7 @@
void
memNodeWriteComplete(void* d)
{
- mem_node* n = (mem_node*)((char*)d - _mem_node_data_offset);
+ mem_node* n = (mem_node*)(d - _mem_node_data_offset);
assert(n->write_pending);
n->write_pending = 0;
}