* Removes last character added, if any.
*/
static inline int agxbpop(agxbuf *xb) {
- int c;
- if (xb->ptr > xb->buf) {
- c = *xb->ptr--;
- return c;
- } else
+
+ if (agxblen(xb) == 0) {
return -1;
+ }
+
+ int c = *xb->ptr--;
+ return c;
}
/* agxbmore:
nsize = size == 0 ? BUFSIZ : (2 * size);
if (size + ssz > nsize)
nsize = size + ssz;
- cnt = (size_t)(xb->ptr - xb->buf);
+ cnt = agxblen(xb);
if (xb->located == AGXBUF_ON_HEAP) {
nbuf = (char *)gv_recalloc(xb->buf, size, nsize, sizeof(char));
} else {