MINOR: buffer: Use b_add()/bo_add() instead of accessing b->i/b->o.
Use the newly available functions instead of using the buffer fields directly.
diff --git a/src/buffer.c b/src/buffer.c
index fe756f7..b4b6e1a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -101,7 +101,7 @@
if (len)
memcpy(pos, str, len);
- b->i += delta;
+ b_add(b, delta);
b_realign_if_empty(b);
return delta;
@@ -141,7 +141,7 @@
pos[len + 1] = '\n';
}
- b->i += delta;
+ b_add(b, delta);
return delta;
}
diff --git a/src/cache.c b/src/cache.c
index f66106d..b86d7bd 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -560,7 +560,7 @@
si_applet_cant_put(si);
goto out;
}
- res->buf->i += len;
+ b_add(res->buf, len);
res->total += len;
appctx->st0 = HTTP_CACHE_FWD;
}
diff --git a/src/channel.c b/src/channel.c
index 024f274..2a75042 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -96,9 +96,9 @@
if (len > max)
return max;
- memcpy(chn->buf->p, msg, len);
- chn->buf->o += len;
- chn->buf->p = c_ptr(chn, len);
+ memcpy(b_tail(chn->buf), msg, len);
+ b_add(chn->buf, len);
+ c_adv(chn, len);
chn->total += len;
return -1;
}
@@ -171,7 +171,7 @@
if (len > max)
memcpy(b_orig(chn->buf), blk + max, len - max);
- chn->buf->i += len;
+ b_add(chn->buf, len);
chn->total += len;
if (chn->to_forward) {
unsigned long fwd = len;
diff --git a/src/compression.c b/src/compression.c
index 397fd94..2abe904 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -229,7 +229,7 @@
memcpy(out_data, in_data, in_len);
- out->i += in_len;
+ b_add(out, in_len);
return in_len;
}
@@ -308,7 +308,7 @@
}
b_reset(tmpbuf);
memcpy(b_tail(tmpbuf), comp_ctx->direct_ptr, comp_ctx->direct_len);
- tmpbuf->i += comp_ctx->direct_len;
+ b_add(tmpbuf, comp_ctx->direct_len);
comp_ctx->direct_ptr = NULL;
comp_ctx->direct_len = 0;
comp_ctx->queued = tmpbuf;
@@ -318,7 +318,7 @@
if (comp_ctx->queued) {
/* data already pending */
memcpy(b_tail(comp_ctx->queued), in_data, in_len);
- comp_ctx->queued->i += in_len;
+ b_add(comp_ctx->queued, in_len);
return in_len;
}
@@ -350,10 +350,10 @@
out_len = out->i;
if (in_ptr)
- out->i += slz_encode(strm, b_tail(out), in_ptr, in_len, !finish);
+ b_add(out, slz_encode(strm, b_tail(out), in_ptr, in_len, !finish));
if (finish)
- out->i += slz_finish(strm, b_tail(out));
+ b_add(out, slz_finish(strm, b_tail(out)));
out_len = out->i - out_len;
@@ -589,7 +589,7 @@
return -1;
/* deflate update the available data out */
- out->i += out_len - strm->avail_out;
+ b_add(out, out_len - strm->avail_out);
return in_len - strm->avail_in;
}
@@ -610,7 +610,7 @@
return -1;
out_len = b_room(out) - strm->avail_out;
- out->i += out_len;
+ b_add(out, out_len);
/* compression limit */
if ((global.comp_rate_lim > 0 && (read_freq_ctr(&global.comp_bps_out) > global.comp_rate_lim)) || /* rate */
diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index 9365364..85abb84 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -212,7 +212,7 @@
memcpy(b_tail(tmpbuf)+block, buf->data, len-block);
c_rew(chn, *nxt);
- tmpbuf->i += len;
+ b_add(tmpbuf, len);
ret = len;
}
else {
@@ -770,10 +770,10 @@
if (ib->i > 0) {
left = ci_contig_data(chn);
memcpy(ob->p + ob->i, ci_head(chn), left);
- ob->i += left;
+ b_add(ob, left);
if (ib->i - left) {
memcpy(ob->p + ob->i, ib->data, ib->i - left);
- ob->i += ib->i - left;
+ b_add(ob, ib->i - left);
}
}
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 81772db..934c949 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -2742,7 +2742,7 @@
/* now consume the input data */
b_del(h2c->dbuf, h2c->dfl);
h2c->st0 = H2_CS_FRAME_H;
- buf->i += outlen;
+ b_add(buf, outlen);
/* don't send it before returning data!
* FIXME: should we instead try to send it much later, after the
@@ -3091,7 +3091,7 @@
/* commit the H2 response */
h2c->mbuf->p = b_peek(h2c->mbuf, h2c->mbuf->o + outbuf.len);
- h2c->mbuf->o += outbuf.len;
+ bo_add(h2c->mbuf, outbuf.len);
h2s->flags |= H2_SF_HEADERS_SENT;
/* for now we don't implemented CONTINUATION, so we wait for a
@@ -3337,7 +3337,7 @@
/* commit the H2 response */
h2c->mbuf->p = b_peek(h2c->mbuf, h2c->mbuf->o + size + 9);
- h2c->mbuf->o += size + 9;
+ bo_add(h2c->mbuf, size + 9);
/* consume incoming H1 response */
if (size > 0) {
diff --git a/src/raw_sock.c b/src/raw_sock.c
index e0bfd1d..375c453 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -294,7 +294,7 @@
ret = recv(conn->handle.fd, b_tail(buf), try, 0);
if (ret > 0) {
- buf->i += ret;
+ b_add(buf, ret);
done += ret;
if (ret < try) {
/* unfortunately, on level-triggered events, POLL_HUP
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index b473027..9e3341a 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -5374,7 +5374,7 @@
done++;
try--;
count--;
- buf->i++;
+ b_add(buf, 1);
conn->tmp_early_data = -1;
continue;
}
@@ -5421,7 +5421,7 @@
goto out_error;
}
if (ret > 0) {
- buf->i += ret;
+ b_add(buf, ret);
done += ret;
count -= ret;
}