- /* No need to move head if shbuf->head <= old_tail,
- * else... */
- if (old_tail < G.shbuf->head && G.shbuf->head <= new_tail) {
- /* ...need to move head forward */
- c = memchr(G.shbuf->data + new_tail, '\0',
- G.shbuf->size - new_tail);
- if (!c) /* no NUL ahead of us, wrap around */
- c = memchr(G.shbuf->data, '\0', old_tail);
- if (!c) { /* still nothing? point to this msg... */
- G.shbuf->head = old_tail;
- } else {
- /* convert pointer to offset + skip NUL */
- G.shbuf->head = c - G.shbuf->data + 1;
- }
- }