コード例 #1
0
ファイル: subr_sbuf.c プロジェクト: 2trill2spill/freebsd
/*
 * Return the length of the sbuf data.
 */
ssize_t
sbuf_len(struct sbuf *s)
{

	assert_sbuf_integrity(s);
	/* don't care if it's finished or not */
	KASSERT(s->s_drain_func == NULL,
	    ("%s makes no sense on sbuf %p with drain", __func__, s));

	if (s->s_error != 0)
		return (-1);

	/* If finished, nulterm is already in len, else add one. */
	if (SBUF_NULINCLUDED(s) && !SBUF_ISFINISHED(s))
		return (s->s_len + 1);
	return (s->s_len);
}
コード例 #2
0
ファイル: subr_sbuf.c プロジェクト: 2trill2spill/freebsd
static void
_assert_sbuf_integrity(const char *fun, struct sbuf *s)
{

	KASSERT(s != NULL,
	    ("%s called with a NULL sbuf pointer", fun));
	KASSERT(s->s_buf != NULL,
	    ("%s called with uninitialized or corrupt sbuf", fun));
	if (SBUF_ISFINISHED(s) && SBUF_NULINCLUDED(s)) {
		KASSERT(s->s_len <= s->s_size,
		    ("wrote past end of sbuf (%jd >= %jd)",
		    (intmax_t)s->s_len, (intmax_t)s->s_size));
	} else {
		KASSERT(s->s_len < s->s_size,
		    ("wrote past end of sbuf (%jd >= %jd)",
		    (intmax_t)s->s_len, (intmax_t)s->s_size));
	}
}
コード例 #3
0
ファイル: subr_sbuf.c プロジェクト: mihaicarabas/dragonfly
/*
 * Check if an sbuf has been finished.
 */
int
sbuf_done(const struct sbuf *s)
{

	return (SBUF_ISFINISHED(s));
}