From 6e21cdaf9d127946d169365c4f86fd09182b2de2 Mon Sep 17 00:00:00 2001 From: Richard Aas Date: Mon, 7 Feb 2011 11:40:51 +0000 Subject: [PATCH] added mbuf_debug() --- include/re_mbuf.h | 2 ++ src/mbuf/mbuf.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/re_mbuf.h b/include/re_mbuf.h index cf13323..8cc1991 100644 --- a/include/re_mbuf.h +++ b/include/re_mbuf.h @@ -38,6 +38,7 @@ struct mbuf { struct pl; +struct re_printf; struct mbuf *mbuf_alloc(size_t size); struct mbuf *mbuf_alloc_ref(struct mbuf *mbr); @@ -63,6 +64,7 @@ int mbuf_vprintf(struct mbuf *mb, const char *fmt, va_list ap); int mbuf_printf(struct mbuf *mb, const char *fmt, ...); int mbuf_write_pl_skip(struct mbuf *mb, const struct pl *pl, const struct pl *skip); +int mbuf_debug(struct re_printf *pf, const struct mbuf *mb); /** diff --git a/src/mbuf/mbuf.c b/src/mbuf/mbuf.c index 4d83cd1..99e6d6f 100644 --- a/src/mbuf/mbuf.c +++ b/src/mbuf/mbuf.c @@ -499,3 +499,13 @@ int mbuf_write_pl_skip(struct mbuf *mb, const struct pl *pl, return mbuf_write_mem(mb, (const uint8_t *)r.p, r.l); } + + +int mbuf_debug(struct re_printf *pf, const struct mbuf *mb) +{ + if (!mb) + return 0; + + return re_hprintf(pf, "buf=%p pos=%zu end=%zu size=%zu", + mb->buf, mb->pos, mb->end, mb->size); +}