From 9a45253afafb7271091e0ac0c91bccfb71d2bfb4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 3 Aug 2008 20:52:08 +0000 Subject: [PATCH] * add method to duplicate stringbuffer --- libcitadel/lib/libcitadel.h | 1 + libcitadel/lib/stringbuf.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 68c60429d..81415177d 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -203,6 +203,7 @@ void the_mime_parser(char *partnum, typedef struct StrBuf StrBuf; StrBuf* NewStrBuf(void); +StrBuf* NewStrBufDup(const StrBuf *CopyMe); StrBuf* NewStrBufPlain(const char* ptr, int nChars); int StrBufPlain(StrBuf *Buf, const char* ptr, int nChars); StrBuf* _NewConstStrBuf(const char* StringConstant, size_t SizeOfStrConstant); diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 5a5e39854..8f6bb5b4a 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -44,6 +44,18 @@ StrBuf* NewStrBuf(void) return NewBuf; } +StrBuf* NewStrBufDup(const StrBuf *CopyMe) +{ + StrBuf *NewBuf; + + if (CopyMe == NULL) + return NewStrBuf(); + + NewBuf = (StrBuf*) malloc(sizeof(StrBuf)); + NewBuf->buf = (char*) malloc(CopyMe->BufSize); + memcpy(NewBuf->buf, CopyMe->buf, CopyMe->BufUsed + 1); + return NewBuf; +} StrBuf* NewStrBufPlain(const char* ptr, int nChars) { -- 2.39.2