From: Jaroslav Kysela Date: Thu, 13 Dec 2018 16:54:39 +0000 (+0100) Subject: sbuf: add sbuf_replace() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=279f689bdf798992ee0bd43dcedb34ef831d6c71;p=thirdparty%2Ftvheadend.git sbuf: add sbuf_replace() --- diff --git a/src/sbuf.h b/src/sbuf.h index d5aa53042..2969e6c94 100644 --- a/src/sbuf.h +++ b/src/sbuf.h @@ -66,6 +66,8 @@ static inline void sbuf_alloc(sbuf_t *sb, int len) void sbuf_realloc(sbuf_t *sb, int len); +void sbuf_replace(sbuf_t *sb, sbuf_t *src); + void sbuf_append(sbuf_t *sb, const void *data, int len); void sbuf_append_from_sbuf(sbuf_t *sb, sbuf_t *src); diff --git a/src/utils.c b/src/utils.c index 7af41da4e..0c73b2e44 100644 --- a/src/utils.c +++ b/src/utils.c @@ -409,6 +409,14 @@ sbuf_realloc(sbuf_t *sb, int len) sbuf_alloc_fail(len); } +void +sbuf_replace(sbuf_t *sb, sbuf_t *src) +{ + sbuf_free(sb); + *sb = *src; + sbuf_init(src); +} + void sbuf_append(sbuf_t *sb, const void *data, int len) {