return res;
}
-static inline const char * mbuf_get_string(MBuf *buf)
-{
- const char *res = (const char *)buf->pos;
- while (buf->pos < buf->end && *buf->pos)
- buf->pos++;
- if (buf->pos == buf->end)
- return NULL;
- buf->pos++;
- return res;
-}
-
static inline unsigned mbuf_avail(MBuf *buf)
{
return buf->end - buf->pos;
return buf->end - buf->data;
}
+static inline const char * mbuf_get_string(MBuf *buf)
+{
+ const char *res = (const char *)buf->pos;
+ const uint8 *nul = memchr(res, 0, mbuf_avail(buf));
+ if (!nul)
+ return NULL;
+ buf->pos = nul + 1;
+ return res;
+}
+