v = u;
/* Handle anything left in our buffer first */
- i = bp - q;
+ i = pdiff(q, bp);
assert(i >= 0);
if (i > v)
i = v;
assert(u == 0);
/* We might still have stuff in our buffer */
- v = bp - q;
+ v = pdiff(q, bp);
if (v > 0)
memcpy(buf, q, v);
q = bp = buf + v;
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
/* Filter into object */
hp2 = &sp->obj->http;
- len = hp->rx_e - hp->rx_s;
+ len = pdiff(hp->rx_s, hp->rx_e);
len += 256; /* margin for content-length etc */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
for (q = p + 1; *q; q++)
if (*q == ',' || isspace(*q))
break;
- i = q - p;
+ i = pdiff(p, q);
if (i == 5 && !strncasecmp(p, "close", i))
sp->doclose = "Connection: close";
u = http_findhdr(hp, i, p);
return (0);
if (len == 0)
- len = hp->pl_e - hp->pl_s;
+ len = pdiff(hp->pl_s, hp->pl_e);
if (hp->pl_s + len > hp->pl_e)
- len = hp->pl_e - hp->pl_s;
+ len = pdiff(hp->pl_s, hp->pl_e);
if (len == 0)
return (0);
*b = hp->pl_s;
u = 0;
if (hp->pl_s < hp->pl_e) {
- u = hp->pl_e - hp->pl_s;
+ u = pdiff(hp->pl_s, hp->pl_e);
if (u > len)
u = len;
memcpy(b, hp->pl_s, u);
hp->rx_e = hp->rx_s;
if (hp->pl_s != NULL) {
assert(hp->pl_s < hp->pl_e);
- l = hp->pl_e - hp->pl_s;
+ l = pdiff(hp->pl_s, hp->pl_s);
memmove(hp->rx_s, hp->pl_s, l);
hp->rx_e = hp->rx_s + l;
hp->pl_s = hp->pl_e = NULL;
unsigned l;
int i;
- l = (hp->ws->e - hp->rx_e) - 1;
+ l = pdiff(hp->rx_e, hp->ws->e) - 1;
l /= 2; /* Don't fill all of workspace with read-ahead */
if (l <= 1) {
VSL(SLT_HttpError, fd, "Received too much");
WSLH(w, htt, fd, hp, u);
continue;
}
- l = hp->hd[u].e - hp->hd[u].b;
+ l = pdiff(hp->hd[u].b, hp->hd[u].e);
p = WS_Alloc(hp->ws, l + 1);
if (p != NULL) {
WSLH(w, htt, fd, hp, u);