revert between 56095 -> 55830 in arch
[AROS.git] / compiler / arossupport / createbstr.c
blob5cba54273bc03d92f3d82873466ae8d2102338ca
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/bptr.h>
7 #include <proto/arossupport.h>
8 #include <proto/exec.h>
10 #include <string.h>
12 BSTR CreateBSTR(CONST_STRPTR src)
14 STRPTR dst;
15 ULONG len = strlen(src);
16 ULONG size = AROS_BSTR_MEMSIZE4LEN(len);
18 dst = AllocVec(size, MEMF_ANY);
19 if (!dst)
20 return BNULL;
22 #ifdef AROS_FAST_BSTR
23 CopyMem(src, dst, size);
24 #else
25 /* Our BSTR's are also NUL-terminated: len + 1 */
26 CopyMem(src, dst + 1, len + 1);
27 dst[0] = len;
28 #endif
30 return MKBADDR(dst);