Just like the existing virBufferTrim, but only
does one thing at a time.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
virBufferStrcatVArgs;
virBufferTrim;
virBufferTrimChars;
+virBufferTrimLen;
virBufferURIEncodeString;
virBufferUse;
virBufferVasprintf;
g_string_truncate(buf->str, i + 1);
}
+/**
+ * virBufferTrimLen:
+ * @buf: the buffer to trim
+ * @len: the number of bytes to trim
+ *
+ * Trim the tail of a buffer.
+ */
+void
+virBufferTrimLen(virBufferPtr buf, int len)
+{
+ if (!buf || !buf->str)
+ return;
+
+ if (len > buf->str->len)
+ return;
+
+ g_string_truncate(buf->str, buf->str->len - len);
+}
+
/**
* virBufferAddStr:
* @buf: the buffer to append to
void virBufferTrim(virBufferPtr buf, const char *trim, int len);
void virBufferTrimChars(virBufferPtr buf, const char *trim);
+void virBufferTrimLen(virBufferPtr buf, int len);
void virBufferAddStr(virBufferPtr buf, const char *str);