MEDIUM: buffers: rename a number of buffer management functions

The following renaming took place :
1) buffer input functions
  buffer_put_block => bi_putblk
  buffer_put_char => bi_putchr
  buffer_put_string => bi_putstr
  buffer_put_chunk => bi_putchk
  buffer_feed => bi_putstr
  buffer_feed_chunk => bi_putchk
  buffer_cut_tail => bi_erase
  buffer_ignore => bi_fast_delete

2) buffer output functions
  buffer_get_char => bo_getchr
  buffer_get_line => bo_getline
  buffer_get_block => bo_getblk
  buffer_skip => bo_skip
  buffer_write => bo_inject

3) buffer input avail/full functions were introduced :
  bi_avail
  bi_full
diff --git a/src/buffers.c b/src/buffers.c
index 2bd24a8..e71f852 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -96,7 +96,7 @@
  * Note: this function appends data to the buffer's output and possibly overwrites
  * any pending input data which are assumed not to exist.
  */
-int buffer_write(struct buffer *buf, const char *msg, int len)
+int bo_inject(struct buffer *buf, const char *msg, int len)
 {
 	int max;
 
@@ -123,7 +123,7 @@
 	buf->total += len;
 
 	buf->flags &= ~(BF_OUT_EMPTY|BF_FULL);
-	if (buffer_len(buf) >= buffer_max_len(buf))
+	if (bi_full(buf))
 		buf->flags |= BF_FULL;
 
 	return -1;
@@ -136,7 +136,7 @@
  * flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
  * transferred.
  */
-int buffer_put_char(struct buffer *buf, char c)
+int bi_putchr(struct buffer *buf, char c)
 {
 	if (unlikely(buffer_input_closed(buf)))
 		return -2;
@@ -147,7 +147,7 @@
 	*bi_end(buf) = c;
 
 	buf->i++;
-	if (buffer_len(buf) >= buffer_max_len(buf))
+	if (bi_full(buf))
 		buf->flags |= BF_FULL;
 	buf->flags |= BF_READ_PARTIAL;
 
@@ -171,7 +171,7 @@
  * Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
  * transferred.
  */
-int buffer_put_block(struct buffer *buf, const char *blk, int len)
+int bi_putblk(struct buffer *buf, const char *blk, int len)
 {
 	int max;
 
@@ -212,7 +212,7 @@
 	}
 
 	buf->flags &= ~BF_FULL;
-	if (buffer_len(buf) >= buffer_max_len(buf))
+	if (bi_full(buf))
 		buf->flags |= BF_FULL;
 
 	/* notify that some data was read from the SI into the buffer */
@@ -225,12 +225,12 @@
  *   >0 : number of bytes read. Includes the \n if present before len or end.
  *   =0 : no '\n' before end found. <str> is left undefined.
  *   <0 : no more bytes readable because output is shut.
- * The buffer status is not changed. The caller must call buffer_skip() to
+ * The buffer status is not changed. The caller must call bo_skip() to
  * update it. The '\n' is waited for as long as neither the buffer nor the
  * output are full. If either of them is full, the string may be returned
  * as is, without the '\n'.
  */
-int buffer_get_line(struct buffer *buf, char *str, int len)
+int bo_getline(struct buffer *buf, char *str, int len)
 {
 	int ret, max;
 	char *p;
@@ -275,10 +275,10 @@
  *   >0 : number of bytes read, equal to requested size.
  *   =0 : not enough data available. <blk> is left undefined.
  *   <0 : no more bytes readable because output is shut.
- * The buffer status is not changed. The caller must call buffer_skip() to
+ * The buffer status is not changed. The caller must call bo_skip() to
  * update it.
  */
-int buffer_get_block(struct buffer *buf, char *blk, int len, int offset)
+int bo_getblk(struct buffer *buf, char *blk, int len, int offset)
 {
 	int firstblock;
 
@@ -343,7 +343,7 @@
 	b->flags &= ~BF_FULL;
 	if (buffer_len(b) == 0)
 		b->p = b->data;
-	if (buffer_len(b) >= buffer_max_len(b))
+	if (bi_full(b))
 		b->flags |= BF_FULL;
 
 	return delta;
@@ -381,7 +381,7 @@
 	b->i += delta;
 
 	b->flags &= ~BF_FULL;
-	if (buffer_len(b) >= buffer_max_len(b))
+	if (bi_full(b))
 		b->flags |= BF_FULL;
 
 	return delta;
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 106ea8c..cddbc3e 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -428,7 +428,7 @@
 	if (target && s->listener->perm.ux.level < ACCESS_LVL_OPER)
 		chunk_printf(msg, "# contents not dumped due to insufficient privileges\n");
 
-	if (buffer_feed_chunk(si->ib, msg) >= 0)
+	if (bi_putchk(si->ib, msg) == -1)
 		return 0;
 
 	return 1;
@@ -499,7 +499,7 @@
 	}
 	chunk_printf(msg, "\n");
 
-	if (buffer_feed_chunk(si->ib, msg) >= 0)
+	if (bi_putchk(si->ib, msg) == -1)
 		return 0;
 
 	return 1;
@@ -924,7 +924,7 @@
 
 			/* return server's effective weight at the moment */
 			snprintf(trash, sizeof(trash), "%d (initial %d)\n", sv->uweight, sv->iweight);
-			buffer_feed(si->ib, trash);
+			bi_putstr(si->ib, trash);
 			return 1;
 		}
 		else { /* not "get weight" */
@@ -1386,7 +1386,7 @@
 			if (buffer_almost_full(si->ib))
 				break;
 
-			reql = buffer_get_line(si->ob, trash, sizeof(trash));
+			reql = bo_getline(si->ob, trash, sizeof(trash));
 			if (reql <= 0) { /* closed or EOL not found */
 				if (reql == 0)
 					break;
@@ -1446,7 +1446,7 @@
 			}
 
 			/* re-adjust req buffer */
-			buffer_skip(si->ob, reql);
+			bo_skip(si->ob, reql);
 			req->flags |= BF_READ_DONTWAIT; /* we plan to read small requests */
 		}
 		else {	/* output functions: first check if the output buffer is closed then abort */
@@ -1457,7 +1457,7 @@
 
 			switch (si->applet.st0) {
 			case STAT_CLI_PRINT:
-				if (buffer_feed(si->ib, si->applet.ctx.cli.msg) < 0)
+				if (bi_putstr(si->ib, si->applet.ctx.cli.msg) != -1)
 					si->applet.st0 = STAT_CLI_PROMPT;
 				break;
 			case STAT_CLI_O_INFO:
@@ -1487,7 +1487,7 @@
 
 			/* The post-command prompt is either LF alone or LF + '> ' in interactive mode */
 			if (si->applet.st0 == STAT_CLI_PROMPT) {
-				if (buffer_feed(si->ib, si->applet.st1 ? "\n> " : "\n") < 0)
+				if (bi_putstr(si->ib, si->applet.st1 ? "\n> " : "\n") != -1)
 					si->applet.st0 = STAT_CLI_GETREQ;
 			}
 
@@ -1573,7 +1573,7 @@
 	case STAT_ST_HEAD:
 		if (si->applet.ctx.stats.flags & STAT_SHOW_STAT) {
 			print_csv_header(&msg);
-			if (buffer_feed_chunk(si->ib, &msg) >= 0)
+			if (bi_putchk(si->ib, &msg) == -1)
 				return 0;
 		}
 
@@ -1623,7 +1623,7 @@
 				     nb_tasks_cur, run_queue_cur, idle_pct,
 				     global.node, global.desc?global.desc:""
 				     );
-			if (buffer_feed_chunk(si->ib, &msg) >= 0)
+			if (bi_putchk(si->ib, &msg) == -1)
 				return 0;
 		}
 
@@ -1696,7 +1696,7 @@
 				stat_status_codes[STAT_STATUS_UNKN]);
 		chunk_printf(&msg, "\r\n\r\n");
 
-		if (buffer_feed_chunk(si->ib, &msg) >= 0)
+		if (bi_putchk(si->ib, &msg) == -1)
 			return 0;
 
 		s->txn.status = 303;
@@ -1800,7 +1800,7 @@
 		chunk_printf(&msg, "\r\n");
 
 		s->txn.status = 200;
-		if (buffer_feed_chunk(rep, &msg) >= 0)
+		if (bi_putchk(rep, &msg) == -1)
 			return 0;
 
 		if (!(s->flags & SN_ERR_MASK))  // this is not really an error but it is
@@ -1915,7 +1915,7 @@
 		} else {
 			print_csv_header(&msg);
 		}
-		if (buffer_feed_chunk(rep, &msg) >= 0)
+		if (bi_putchk(rep, &msg) == -1)
 			return 0;
 
 		si->applet.state = STAT_ST_INFO;
@@ -2090,7 +2090,7 @@
 				chunk_printf(&msg,"<p>\n");
 			}
 
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -2121,7 +2121,7 @@
 	case STAT_ST_END:
 		if (!(si->applet.ctx.stats.flags & STAT_FMT_CSV)) {
 			chunk_printf(&msg, "</body></html>\n");
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -2250,7 +2250,7 @@
 				     "<th>Thrtle</th>\n"
 				     "</tr>");
 
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -2407,7 +2407,7 @@
 				chunk_printf(&msg, "\n");
 			}
 
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -2543,7 +2543,7 @@
 				     relative_pid, px->uuid, l->luid, STATS_TYPE_SO);
 			}
 
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -2953,7 +2953,7 @@
 				/* finish with EOL */
 				chunk_printf(&msg, "\n");
 			}
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		} /* for sv */
 
@@ -3148,7 +3148,7 @@
 				chunk_printf(&msg, "\n");
 
 			}
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -3176,7 +3176,7 @@
 
 			chunk_printf(&msg, "<p>\n");
 
-			if (buffer_feed_chunk(rep, &msg) >= 0)
+			if (bi_putchk(rep, &msg) == -1)
 				return 0;
 		}
 
@@ -3212,7 +3212,7 @@
 	if (si->applet.ctx.sess.section > 0 && si->applet.ctx.sess.uid != sess->uniq_id) {
 		/* session changed, no need to go any further */
 		chunk_printf(&msg, "  *** session terminated while we were watching it ***\n");
-		if (buffer_feed_chunk(si->ib, &msg) >= 0)
+		if (bi_putchk(si->ib, &msg) == -1)
 			return 0;
 		si->applet.ctx.sess.target = NULL;
 		si->applet.ctx.sess.uid = 0;
@@ -3427,7 +3427,7 @@
 			     sess->txn.rsp.next,
 			     sess->rep->total);
 
-		if (buffer_feed_chunk(si->ib, &msg) >= 0)
+		if (bi_putchk(si->ib, &msg) == -1)
 			return 0;
 
 		/* use other states to dump the contents */
@@ -3611,7 +3611,7 @@
 
 			chunk_printf(&msg, "\n");
 
-			if (buffer_feed_chunk(si->ib, &msg) >= 0) {
+			if (bi_putchk(si->ib, &msg) == -1) {
 				/* let's try again later from this session. We add ourselves into
 				 * this session's users so that it can remove us upon termination.
 				 */
@@ -3630,7 +3630,7 @@
 			else
 				chunk_printf(&msg, "Session not found.\n");
 
-			if (buffer_feed_chunk(si->ib, &msg) >= 0)
+			if (bi_putchk(si->ib, &msg) == -1)
 				return 0;
 
 			si->applet.ctx.sess.target = NULL;
@@ -3890,7 +3890,7 @@
 			     tm.tm_hour, tm.tm_min, tm.tm_sec, (int)(date.tv_usec/1000),
 			     error_snapshot_id);
 
-		if (buffer_feed_chunk(si->ib, &msg) >= 0) {
+		if (bi_putchk(si->ib, &msg) == -1) {
 			/* Socket buffer full. Let's try again later from the same point */
 			return 0;
 		}
@@ -3962,7 +3962,7 @@
 				break;
 			}
 
-			if (buffer_feed_chunk(si->ib, &msg) >= 0) {
+			if (bi_putchk(si->ib, &msg) == -1) {
 				/* Socket buffer full. Let's try again later from the same point */
 				return 0;
 			}
@@ -3974,7 +3974,7 @@
 			/* the snapshot changed while we were dumping it */
 			chunk_printf(&msg,
 				     "  WARNING! update detected on this snapshot, dump interrupted. Please re-check!\n");
-			if (buffer_feed_chunk(si->ib, &msg) >= 0)
+			if (bi_putchk(si->ib, &msg) == -1)
 				return 0;
 			goto next;
 		}
@@ -3989,7 +3989,7 @@
 			if (newptr == si->applet.ctx.errors.ptr)
 				return 0;
 
-			if (buffer_feed_chunk(si->ib, &msg) >= 0) {
+			if (bi_putchk(si->ib, &msg) == -1) {
 				/* Socket buffer full. Let's try again later from the same point */
 				return 0;
 			}
diff --git a/src/peers.c b/src/peers.c
index 6c25dcd..3d2fd01 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -232,7 +232,7 @@
 				si->applet.st0 = PEER_SESSION_GETVERSION;
 				/* fall through */
 			case PEER_SESSION_GETVERSION:
-				reql = buffer_get_line(si->ob, trash, sizeof(trash));
+				reql = bo_getline(si->ob, trash, sizeof(trash));
 				if (reql <= 0) { /* closed or EOL not found */
 					if (reql == 0)
 						goto out;
@@ -248,7 +248,7 @@
 				else
 					trash[reql-1] = 0;
 
-				buffer_skip(si->ob, reql);
+				bo_skip(si->ob, reql);
 
 				/* test version */
 				if (strcmp(PEER_SESSION_PROTO_NAME " 1.0", trash) != 0) {
@@ -263,7 +263,7 @@
 				si->applet.st0 = PEER_SESSION_GETHOST;
 				/* fall through */
 			case PEER_SESSION_GETHOST:
-				reql = buffer_get_line(si->ob, trash, sizeof(trash));
+				reql = bo_getline(si->ob, trash, sizeof(trash));
 				if (reql <= 0) { /* closed or EOL not found */
 					if (reql == 0)
 						goto out;
@@ -279,7 +279,7 @@
 				else
 					trash[reql-1] = 0;
 
-				buffer_skip(si->ob, reql);
+				bo_skip(si->ob, reql);
 
 				/* test hostname match */
 				if (strcmp(localpeer, trash) != 0) {
@@ -293,7 +293,7 @@
 			case PEER_SESSION_GETPEER: {
 				struct peer *curpeer;
 				char *p;
-				reql = buffer_get_line(si->ob, trash, sizeof(trash));
+				reql = bo_getline(si->ob, trash, sizeof(trash));
 				if (reql <= 0) { /* closed or EOL not found */
 					if (reql == 0)
 						goto out;
@@ -310,7 +310,7 @@
 				else
 					trash[reql-1] = 0;
 
-				buffer_skip(si->ob, reql);
+				bo_skip(si->ob, reql);
 
 				/* parse line "<peer name> <pid>" */
 				p = strchr(trash, ' ');
@@ -346,7 +346,7 @@
 				size_t key_size;
 				char *p;
 
-				reql = buffer_get_line(si->ob, trash, sizeof(trash));
+				reql = bo_getline(si->ob, trash, sizeof(trash));
 				if (reql <= 0) { /* closed or EOL not found */
 					if (reql == 0)
 						goto out;
@@ -367,7 +367,7 @@
 				else
 					trash[reql-1] = 0;
 
-				buffer_skip(si->ob, reql);
+				bo_skip(si->ob, reql);
 
 				/* Parse line "<table name> <type> <size>" */
 				p = strchr(trash, ' ');
@@ -448,7 +448,7 @@
 				struct peer_session *ps = (struct peer_session *)si->applet.private;
 
 				repl = snprintf(trash, sizeof(trash), "%d\n", PEER_SESSION_SUCCESSCODE);
-				repl = buffer_put_block(si->ib, trash, repl);
+				repl = bi_putblk(si->ib, trash, repl);
 				if (repl <= 0) {
 					if (repl == -1)
 						goto out;
@@ -512,7 +512,7 @@
 					goto switchstate;
 				}
 
-				repl = buffer_put_block(si->ib, trash, repl);
+				repl = bi_putblk(si->ib, trash, repl);
 				if (repl <= 0) {
 					if (repl == -1)
 						goto out;
@@ -530,7 +530,7 @@
 				if (si->ib->flags & BF_WRITE_PARTIAL)
 					ps->statuscode = PEER_SESSION_CONNECTEDCODE;
 
-				reql = buffer_get_line(si->ob, trash, sizeof(trash));
+				reql = bo_getline(si->ob, trash, sizeof(trash));
 				if (reql <= 0) { /* closed or EOL not found */
 					if (reql == 0)
 						goto out;
@@ -547,7 +547,7 @@
 				else
 					trash[reql-1] = 0;
 
-				buffer_skip(si->ob, reql);
+				bo_skip(si->ob, reql);
 
 				/* Register status code */
 				ps->statuscode = atoi(trash);
@@ -600,7 +600,7 @@
 				char c;
 				int totl = 0;
 
-				reql = buffer_get_block(si->ob, (char *)&c, sizeof(c), totl);
+				reql = bo_getblk(si->ob, (char *)&c, sizeof(c), totl);
 				if (reql <= 0) { /* closed or EOL not found */
 					if (reql == 0) {
 						/* nothing to read */
@@ -625,7 +625,7 @@
 						pushack = ps->pushack + (unsigned int)(c & 0x7F);
 					}
 					else {
-						reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+						reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
 						if (reql <= 0) { /* closed or EOL not found */
 							if (reql == 0) {
 								goto incomplete;
@@ -642,7 +642,7 @@
 						/* type string */
 						stkey.key = stkey.data.buf;
 
-						reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+						reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
 						if (reql <= 0) { /* closed or EOL not found */
 							if (reql == 0) {
 								goto incomplete;
@@ -653,7 +653,7 @@
 						totl += reql;
 						stkey.key_len = ntohl(netinteger);
 
-						reql = buffer_get_block(si->ob, stkey.key, stkey.key_len, totl);
+						reql = bo_getblk(si->ob, stkey.key, stkey.key_len, totl);
 						if (reql <= 0) { /* closed or EOL not found */
 							if (reql == 0) {
 								goto incomplete;
@@ -668,7 +668,7 @@
 						stkey.key_len = (size_t)-1;
 						stkey.key = &stkey.data.integer;
 
-						reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+						reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
 						if (reql <= 0) { /* closed or EOL not found */
 							if (reql == 0) {
 								goto incomplete;
@@ -684,7 +684,7 @@
 						stkey.key_len = (size_t)-1;
 						stkey.key = stkey.data.buf;
 
-						reql = buffer_get_block(si->ob, (char *)&stkey.data.buf, ps->table->table->key_size, totl);
+						reql = bo_getblk(si->ob, (char *)&stkey.data.buf, ps->table->table->key_size, totl);
 						if (reql <= 0) { /* closed or EOL not found */
 							if (reql == 0) {
 								goto incomplete;
@@ -697,7 +697,7 @@
 					}
 
 					/* read server id */
-					reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+					reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
 					if (reql <= 0) { /* closed or EOL not found */
 						if (reql == 0) {
 							goto incomplete;
@@ -806,7 +806,7 @@
 					/* ack message */
 					uint32_t netinteger;
 
-					reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+					reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
 					if (reql <= 0) { /* closed or EOL not found */
 						if (reql == 0) {
 							goto incomplete;
@@ -826,7 +826,7 @@
 				}
 
 				/* skip consumed message */
-				buffer_skip(si->ob, totl);
+				bo_skip(si->ob, totl);
 
 				/* loop on that state to peek next message */
 				continue;
@@ -836,7 +836,7 @@
 				/* Confirm finished or partial messages */
 				while (ps->confirm) {
 					/* There is a confirm messages to send */
-					repl = buffer_put_char(si->ib, 'c');
+					repl = bi_putchr(si->ib, 'c');
 					if (repl <= 0) {
 						/* no more write possible */
 						if (repl == -1)
@@ -853,7 +853,7 @@
 					!(ps->table->flags & SHTABLE_F_RESYNC_PROCESS)) {
 					/* Current peer was elected to request a resync */
 
-					repl = buffer_put_char(si->ib, 'R');
+					repl = bi_putchr(si->ib, 'R');
 					if (repl <= 0) {
 						/* no more write possible */
 						if (repl == -1)
@@ -872,7 +872,7 @@
 					netinteger = htonl(ps->pushack);
 					memcpy(&trash[1], &netinteger, sizeof(netinteger));
 
-					repl = buffer_put_block(si->ib, trash, 1+sizeof(netinteger));
+					repl = bi_putblk(si->ib, trash, 1+sizeof(netinteger));
 					if (repl <= 0) {
 						/* no more write possible */
 						if (repl == -1)
@@ -908,7 +908,7 @@
 							msglen = peer_prepare_datamsg(ts, ps, trash, sizeof(trash));
 							if (msglen) {
 								/* message to buffer */
-								repl = buffer_put_block(si->ib, trash, msglen);
+								repl = bi_putblk(si->ib, trash, msglen);
 								if (repl <= 0) {
 									/* no more write possible */
 									if (repl == -1)
@@ -942,7 +942,7 @@
 							msglen = peer_prepare_datamsg(ts, ps, trash, sizeof(trash));
 							if (msglen) {
 								/* message to buffer */
-								repl = buffer_put_block(si->ib, trash, msglen);
+								repl = bi_putblk(si->ib, trash, msglen);
 								if (repl <= 0) {
 									/* no more write possible */
 									if (repl == -1)
@@ -958,7 +958,7 @@
 
 					if (!(ps->flags & PEER_F_TEACH_FINISHED)) {
 						/* process final lesson message */
-						repl = buffer_put_char(si->ib, ((ps->table->flags & SHTABLE_RESYNC_STATEMASK) == SHTABLE_RESYNC_FINISHED) ? 'F' : 'C');
+						repl = bi_putchr(si->ib, ((ps->table->flags & SHTABLE_RESYNC_STATEMASK) == SHTABLE_RESYNC_FINISHED) ? 'F' : 'C');
 						if (repl <= 0) {
 							/* no more write possible */
 							if (repl == -1)
@@ -1000,7 +1000,7 @@
 						msglen = peer_prepare_datamsg(ts, ps, trash, sizeof(trash));
 						if (msglen) {
 							/* message to buffer */
-							repl = buffer_put_block(si->ib, trash, msglen);
+							repl = bi_putblk(si->ib, trash, msglen);
 							if (repl <= 0) {
 								/* no more write possible */
 								if (repl == -1)
@@ -1019,7 +1019,7 @@
 			case PEER_SESSION_EXIT:
 				repl = snprintf(trash, sizeof(trash), "%d\n", si->applet.st1);
 
-				if (buffer_put_block(si->ib, trash, repl) == -1)
+				if (bi_putblk(si->ib, trash, repl) == -1)
 					goto out;
 				si->applet.st0 = PEER_SESSION_END;
 				/* fall through */
diff --git a/src/proto_http.c b/src/proto_http.c
index eac0319..476b097 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -656,7 +656,7 @@
 	buffer_auto_read(si->ib);
 	if (status > 0 && msg) {
 		t->txn.status = status;
-		buffer_write(si->ib, msg->str, msg->len);
+		bo_inject(si->ib, msg->str, msg->len);
 	}
 	if (!(t->flags & SN_ERR_MASK))
 		t->flags |= err;
@@ -1308,7 +1308,7 @@
 				if (buf->o)
 					goto http_msg_ood;
 				/* Remove empty leading lines, as recommended by RFC2616. */
-				buffer_ignore(buf, ptr - beg);
+				bi_fast_delete(buf, ptr - beg);
 			}
 			msg->sol = msg->som = ptr - buf->p;
 			hdr_idx_init(idx);
@@ -1375,7 +1375,7 @@
 				if (buf->o)
 					goto http_msg_ood;
 				/* Remove empty leading lines, as recommended by RFC2616. */
-				buffer_ignore(buf, ptr - beg);
+				bi_fast_delete(buf, ptr - beg);
 			}
 			msg->sol = msg->som = ptr - buf->p;
 			/* we will need this when keep-alive will be supported
@@ -1998,7 +1998,7 @@
 	}
 
 	buf->flags &= ~BF_FULL;
-	if (buffer_len(buf) >= buffer_max_len(buf))
+	if (bi_full(buf))
 		buf->flags |= BF_FULL;
 }
 
@@ -2994,7 +2994,7 @@
 						/* Expect is allowed in 1.1, look for it */
 						if (http_find_header2("Expect", 6, req->p + msg->sol, &txn->hdr_idx, &ctx) &&
 						    unlikely(ctx.vlen == 12 && strncasecmp(ctx.line+ctx.val, "100-continue", 12) == 0)) {
-							buffer_write(s->rep, http_100_chunk.str, http_100_chunk.len);
+							bo_inject(s->rep, http_100_chunk.str, http_100_chunk.len);
 						}
 					}
 					msg->msg_state = HTTP_MSG_100_SENT;
@@ -3154,9 +3154,9 @@
 				}
 				memcpy(rdr.str + rdr.len, "\r\n\r\n", 4);
 				rdr.len += 4;
-				buffer_write(req->prod->ob, rdr.str, rdr.len);
+				bo_inject(req->prod->ob, rdr.str, rdr.len);
 				/* "eat" the request */
-				buffer_ignore(req, msg->sov - msg->som);
+				bi_fast_delete(req, msg->sov - msg->som);
 				msg->som = msg->sov;
 				req->analysers = AN_REQ_HTTP_XFER_BODY;
 				s->rep->analysers = AN_RES_HTTP_XFER_BODY;
@@ -3568,7 +3568,7 @@
 			/* Expect is allowed in 1.1, look for it */
 			if (http_find_header2("Expect", 6, req->p + msg->sol, &txn->hdr_idx, &ctx) &&
 			    unlikely(ctx.vlen == 12 && strncasecmp(ctx.line+ctx.val, "100-continue", 12) == 0)) {
-				buffer_write(s->rep, http_100_chunk.str, http_100_chunk.len);
+				bo_inject(s->rep, http_100_chunk.str, http_100_chunk.len);
 			}
 		}
 		msg->msg_state = HTTP_MSG_100_SENT;
@@ -4067,7 +4067,7 @@
 	if (txn->rsp.msg_state == HTTP_MSG_CLOSED) {
 	http_msg_closed:
 		/* drop any pending data */
-		buffer_cut_tail(buf);
+		bi_erase(buf);
 		buffer_auto_close(buf);
 		buffer_auto_read(buf);
 		goto wait_other_side;
@@ -4133,7 +4133,7 @@
 		buffer_abort(s->req);
 		buffer_auto_close(s->req);
 		buffer_auto_read(s->req);
-		buffer_cut_tail(s->req);
+		bi_erase(s->req);
 	}
 	else if (txn->req.msg_state == HTTP_MSG_CLOSED &&
 		 txn->rsp.msg_state == HTTP_MSG_DONE &&
@@ -4542,7 +4542,7 @@
 			rep->analysers = 0;
 			txn->status = 502;
 			rep->prod->flags |= SI_FL_NOLINGER;
-			buffer_cut_tail(rep);
+			bi_erase(rep);
 			stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502));
 
 			if (!(s->flags & SN_ERR_MASK))
@@ -4575,7 +4575,7 @@
 			rep->analysers = 0;
 			txn->status = 502;
 			rep->prod->flags |= SI_FL_NOLINGER;
-			buffer_cut_tail(rep);
+			bi_erase(rep);
 			stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502));
 
 			if (!(s->flags & SN_ERR_MASK))
@@ -4600,7 +4600,7 @@
 			rep->analysers = 0;
 			txn->status = 504;
 			rep->prod->flags |= SI_FL_NOLINGER;
-			buffer_cut_tail(rep);
+			bi_erase(rep);
 			stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_504));
 
 			if (!(s->flags & SN_ERR_MASK))
@@ -4625,7 +4625,7 @@
 			rep->analysers = 0;
 			txn->status = 502;
 			rep->prod->flags |= SI_FL_NOLINGER;
-			buffer_cut_tail(rep);
+			bi_erase(rep);
 			stream_int_retnclose(rep->cons, error_message(s, HTTP_ERR_502));
 
 			if (!(s->flags & SN_ERR_MASK))
@@ -4975,7 +4975,7 @@
 					rep->analysers = 0;
 					txn->status = 502;
 					rep->prod->flags |= SI_FL_NOLINGER;
-					buffer_cut_tail(rep);
+					bi_erase(rep);
 					stream_int_retnclose(rep->cons, error_message(t, HTTP_ERR_502));
 					if (!(t->flags & SN_ERR_MASK))
 						t->flags |= SN_ERR_PRXCOND;
diff --git a/src/stream_interface.c b/src/stream_interface.c
index b8a6d58..cea1a19 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -74,9 +74,9 @@
 	buffer_auto_close(si->ib);
 	buffer_erase(si->ib);
 
-	buffer_cut_tail(si->ob);
+	bi_erase(si->ob);
 	if (likely(msg && msg->len))
-		buffer_write(si->ob, msg->str, msg->len);
+		bo_inject(si->ob, msg->str, msg->len);
 
 	si->ob->wex = tick_add_ifset(now_ms, si->ob->wto);
 	buffer_auto_read(si->ob);
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 575e24c..1b543d0 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -269,9 +269,9 @@
 #endif
 	cur_read = 0;
 	while (1) {
-		max = buffer_max_len(b) - buffer_len(b);
+		max = bi_avail(b);
 
-		if (max <= 0) {
+		if (!max) {
 			b->flags |= BF_FULL;
 			si->flags |= SI_FL_WAIT_ROOM;
 			break;
@@ -318,7 +318,7 @@
 			b->flags |= BF_READ_PARTIAL;
 			b->total += ret;
 
-			if (buffer_len(b) >= buffer_max_len(b)) {
+			if (bi_full(b)) {
 				/* The buffer is now full, there's no point in going through
 				 * the loop again.
 				 */
@@ -646,7 +646,7 @@
 				/* optimize data alignment in the buffer */
 				b->p = b->data;
 
-			if (likely(buffer_len(b) < buffer_max_len(b)))
+			if (likely(!bi_full(b)))
 				b->flags &= ~BF_FULL;
 
 			if (!b->o) {