- Now splits paragraphs into multiple lines, with each line fitting the
[AROS.git] / compiler / arossupport / createbstr.c
blob7a29f66d119037e1c4c83f6ecb370b06b285a050
1 #include <dos/bptr.h>
2 #include <proto/arossupport.h>
3 #include <proto/exec.h>
5 #include <string.h>
7 BSTR CreateBSTR(CONST_STRPTR src)
9 STRPTR dst;
10 ULONG len = strlen(src);
11 ULONG size = AROS_BSTR_MEMSIZE4LEN(len);
13 dst = AllocVec(size, MEMF_ANY);
14 if (!dst)
15 return BNULL;
17 #ifdef AROS_FAST_BSTR
18 CopyMem(src, dst, size);
19 #else
20 /* Our BSTR's are also NUL-terminated: len + 1 */
21 CopyMem(src, dst + 1, len + 1);
22 dst[0] = len;
23 #endif
25 return MKBADDR(dst);