3 // Copyright (c) 1999-2002 by Digital Mars
5 // written by Walter Bright
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
17 Lstring
Lstring::zero
= LSTRING_EMPTY();
19 Lstring
*Lstring::ctor(const dchar
*p
, unsigned length
)
24 memcpy(s
->string
, p
, length
* sizeof(dchar
));
28 Lstring
*Lstring::alloc(unsigned length
)
32 s
= (Lstring
*)mem
.malloc(size(length
));
34 s
->string
[length
] = 0;
38 Lstring
*Lstring::append(const Lstring
*s
)
44 t
= alloc(length
+ s
->length
);
45 memcpy(t
->string
, string
, length
* sizeof(dchar
));
46 memcpy(t
->string
+ length
, s
->string
, s
->length
* sizeof(dchar
));
50 Lstring
*Lstring::substring(int start
, int end
)
56 t
= alloc(end
- start
);
57 memcpy(t
->string
, string
+ start
, (end
- start
) * sizeof(dchar
));