FreeBSD/contrib/libxo/libxo/xo_buf.h
/*
 * Does the buffer have room for the given number of bytes of data?
 * If not, realloc the buffer to make room.  If that fails, we
 * return 0 to tell the caller they are in trouble.
 */
Does the buffer have room for the given number of bytes of data.
If not, realloc the buffer to make room.  If that fails, we
return 0 to tell the caller they are in trouble.
Does the buffer have room for the given number of bytes of data . If not realloc the buffer to make room . If that fails we return 0 to tell the caller they are in trouble .
static inline int
xo_buf_has_room (xo_buffer_t *xbp, int len)
{
    if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
	int sz = xbp->xb_size + XO_BUFSIZ;
	char *bp = xo_realloc(xbp->xb_bufp, sz);
	if (bp == NULL)
	    return 0;
	xbp->xb_curp = bp + (xbp->xb_curp - xbp->xb_bufp);
	xbp->xb_bufp = bp;
	xbp->xb_size = sz;
    }
    return 1;
}
static inline int xo_buf_has_room ( xo_buffer_t * xbp , int len ) { if ( xbp -> xb_curp + len >= xbp -> xb_bufp + xbp -> xb_size ) { int sz = xbp -> xb_size + XO_BUFSIZ ; char * bp = xo_realloc ( xbp -> xb_bufp , sz ) ; if ( bp == NULL ) return 0 ; xbp -> xb_curp = bp + ( xbp -> xb_curp - xbp -> xb_bufp ) ; xbp -> xb_bufp = bp ; xbp -> xb_size = sz ; } return 1 ; }
Does the buffer have room for the given number of bytes of data?
Does the buffer have room for the given number of bytes of data?