From: Martin Wilck <mwilck@xxxxxxxx> Add a function for internal use that allows direct manipulation of the strbuf's content. Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- libmultipath/strbuf.c | 5 +++++ libmultipath/strbuf.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libmultipath/strbuf.c b/libmultipath/strbuf.c index a24a57d..f654594 100644 --- a/libmultipath/strbuf.c +++ b/libmultipath/strbuf.c @@ -15,6 +15,11 @@ static const char empty_str[] = ""; +char *__get_strbuf_buf(struct strbuf *buf) +{ + return buf->buf; +} + const char *get_strbuf_str(const struct strbuf *buf) { return buf->buf ? buf->buf : empty_str; diff --git a/libmultipath/strbuf.h b/libmultipath/strbuf.h index 5903572..41d7d54 100644 --- a/libmultipath/strbuf.h +++ b/libmultipath/strbuf.h @@ -54,6 +54,20 @@ void free_strbuf(struct strbuf *buf); */ struct strbuf *new_strbuf(void); +/** + * get_strbuf_buf(): retrieve a pointer to the strbuf's buffer + * @param buf: a struct strbuf + * @returns: pointer to the string written to the strbuf so far. + * + * INTERNAL ONLY. + * DANGEROUS: Unlike the return value of get_strbuf_str(), + * this string can be written to, modifying the strbuf's content. + * USE WITH CAUTION. + * If @strbuf was never written to, the function returns NULL. + * The return value of this function must not be free()d. + */ +char *__get_strbuf_buf(struct strbuf *buf); + /** * get_strbuf_str(): retrieve string from strbuf * @param buf: a struct strbuf -- 2.33.1 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel