]> code.citadel.org Git - citadel.git/commitdiff
* add method to duplicate stringbuffer
authorWilfried Göesgens <willi@citadel.org>
Sun, 3 Aug 2008 20:52:08 +0000 (20:52 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 3 Aug 2008 20:52:08 +0000 (20:52 +0000)
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index 68c60429d94a52fffbf91b31c6a8492d6d94ba3f..81415177d61e155687d062060f8329e5d1d4b7a0 100644 (file)
@@ -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);
index 5a5e3985488479e750f20247870eea137eb66ed2..8f6bb5b4ad1ec85069f99f66df92bd73a9d67e11 100644 (file)
@@ -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)
 {