udebug: add functions for manipulating entry length
[project/libubox.git] / udebug.c
index 5be9b54d8724a0ac29fe51e7294003a6d3a31deb..00a66abd42e7b74c54e88f179dfee9101629b8e1 100644 (file)
--- a/udebug.c
+++ b/udebug.c
@@ -467,6 +467,25 @@ void *udebug_entry_append(struct udebug_buf *buf, const void *data, uint32_t len
        return ret;
 }
 
+uint16_t udebug_entry_trim(struct udebug_buf *buf, uint16_t len)
+{
+       struct udebug_hdr *hdr = buf->hdr;
+       struct udebug_ptr *ptr = udebug_ring_ptr(hdr, hdr->head);
+
+       if (len)
+               ptr->len -= len;
+
+       return ptr->len;
+}
+
+void udebug_entry_set_length(struct udebug_buf *buf, uint16_t len)
+{
+       struct udebug_hdr *hdr = buf->hdr;
+       struct udebug_ptr *ptr = udebug_ring_ptr(hdr, hdr->head);
+
+       ptr->len = len;
+}
+
 int udebug_entry_printf(struct udebug_buf *buf, const char *fmt, ...)
 {
        va_list ap;