Exemple #1
0
/**
 * Get a reference to the internal buffer.
 *
 * len:
 *	Pointer to where we return the number of bytes in the internal buffer.
 *
 * Returns:
 *	return A pointer to the data.
 */
Byte *
Buf_GetAll(Buffer *bp, size_t *len)
{

	if (len != NULL)
		*len = Buf_Size(bp);

	return (bp->buf);
}
Exemple #2
0
/**
 * Append characters in buf to Buffer object
 */
void
Buf_AppendBuf(Buffer *bp, const Buffer *buf)
{
	Buf_AddBytes(bp, Buf_Size(buf), buf->buf);
}
Exemple #3
-1
/**
 * Expand the buffer to hold the number of additional bytes, plus
 * space to store a terminating NULL byte.
 */
static inline void
BufExpand(Buffer *bp, size_t nb)
{
	size_t	len = Buf_Size(bp);
	if (bp->size < len + nb + 1) {
		int size = bp->size + MAX(nb + 1, BUF_ADD_INC);

		bp->buf		= erealloc(bp->buf, size);
		bp->size	= size;
		bp->end		= bp->buf + len;
	}
}
Exemple #4
-1
void
For_Run(For *arg)
{
	arg->text = Buf_Retrieve(&arg->buf);
	arg->guess = Buf_Size(&arg->buf) + GUESS_EXPANSION;

	arg->var = NULL;
	Lst_ForEach(&arg->lst, ForExec, arg);
	Buf_Destroy(&arg->buf);
	Lst_Destroy(&arg->vars, (SimpleProc)Var_DeleteLoopVar);
	Lst_Destroy(&arg->lst, (SimpleProc)free);
	free(arg);
}