12 byval s
as DSTRING
ptr, _
13 byval chars
as integer, _
14 byval charsize
as integer, _
15 byval dopreserve
as integer _
20 #macro ALLOC_SETUP(dst, chars, _type)
22 if( dst.
data <> NULL )
then
23 deallocate( dst.
data )
31 if( dst.
len <> chars )
then
32 hRealloc(
cast( DSTRING
ptr, @dst ), _
40 #macro REALLOC_SETUP(dst, chars, _type)
45 hRealloc(
cast( DSTRING
ptr, @dst ), _
52 #define CALC_LEN( p )
iif( p <> NULL,
len( *src ), 0 )
61 byref dst
as DZSTRING _
73 byref dst
as DZSTRING, _
74 byval chars
as integer _
77 ALLOC_SETUP( dst, chars,
zstring )
84 byref dst
as DZSTRING _
87 if( dst.
data <> NULL )
then
98 byref dst
as DZSTRING, _
99 byval src
as zstring ptr _
102 dim as integer src_len = CALC_LEN( src )
104 ALLOC_SETUP( dst, src_len,
zstring )
106 if( dst.
data <> NULL )
then
115 byref dst
as DZSTRING, _
116 byval src
as wstring ptr _
119 dim as integer src_len = CALC_LEN( src )
121 ALLOC_SETUP( dst, src_len,
zstring )
123 if( dst.
data <> NULL )
then
132 byref dst
as DZSTRING, _
133 byval src
as uinteger _
136 dim as integer src_len =
len(
zstring )
138 ALLOC_SETUP( dst, src_len,
zstring )
140 if( dst.
data <> NULL )
then
150 byref dst
as DZSTRING, _
151 byval src
as zstring ptr _
154 dim as integer src_len = CALC_LEN( src )
155 dim as integer dst_len = dst.
len
157 REALLOC_SETUP( dst, src_len,
zstring )
159 if( dst.
data <> NULL )
then
160 *(dst.
data + dst_len) = *src
168 byref dst
as DZSTRING, _
169 byval src
as wstring ptr _
172 dim as integer src_len = CALC_LEN( src )
173 dim as integer dst_len = dst.
len
175 REALLOC_SETUP( dst, src_len,
zstring )
177 if( dst.
data <> NULL )
then
178 *(dst.
data + dst_len) = *src
186 byref dst
as DZSTRING, _
187 byval src
as uinteger _
190 dim as integer src_len =
len(
zstring )
191 dim as integer dst_len = dst.
len
193 REALLOC_SETUP( dst, src_len,
zstring )
195 if( dst.
data <> NULL )
then
196 *(dst.
data + dst_len+0) = src
197 *(dst.
data + dst_len+1) = 0
209 byref dst
as DWSTRING _
221 byref dst
as DWSTRING, _
222 byval chars
as integer _
225 ALLOC_SETUP( dst, chars,
wstring )
232 byref dst
as DWSTRING _
235 if( dst.
data <> NULL )
then
246 byref dst
as DWSTRING, _
247 byval src
as wstring ptr _
250 dim as integer src_len = CALC_LEN( src )
252 ALLOC_SETUP( dst, src_len,
wstring )
254 if( dst.
data <> NULL )
then
263 byref dst
as DWSTRING, _
264 byval src
as zstring ptr _
267 dim as integer src_len = CALC_LEN( src )
269 ALLOC_SETUP( dst, src_len,
wstring )
271 if( dst.
data <> NULL )
then
280 byref dst
as DWSTRING, _
281 byval src
as uinteger _
284 dim as integer src_len =
len(
wstring )
286 ALLOC_SETUP( dst, src_len,
wstring )
288 if( dst.
data <> NULL )
then
298 byref dst
as DWSTRING, _
299 byval src
as wstring ptr _
302 dim as integer src_len = CALC_LEN( src )
303 dim as integer dst_len = dst.
len
305 REALLOC_SETUP( dst, src_len,
wstring )
307 if( dst.
data <> NULL )
then
308 *(dst.
data + dst_len) = *src
316 byref dst
as DWSTRING, _
317 byval src
as zstring ptr _
320 dim as integer src_len = CALC_LEN( src )
321 dim as integer dst_len = dst.
len
323 REALLOC_SETUP( dst, src_len,
wstring )
325 if( dst.
data <> NULL )
then
326 *(dst.
data + dst_len) = *src
334 byref dst
as DWSTRING, _
335 byval src
as uinteger _
338 dim as integer src_len =
len(
wstring )
339 dim as integer dst_len = dst.
len
341 REALLOC_SETUP( dst, src_len,
wstring )
343 if( dst.
data <> NULL )
then
344 *(dst.
data + dst_len+0) = src
345 *(dst.
data + dst_len+1) = 0
353 byval s
as DSTRING
ptr, _
354 byval chars
as integer, _
355 byval charsize
as integer, _
356 byval dopreserve
as integer _
359 dim as integer newsize
363 newsize = (chars + 15)
and not 15
365 if( (s->
data = NULL)
or _
366 (chars > s->size)
or _
367 (newsize < (s->size - (s->size
shr 3))) )
then
369 if( dopreserve = FALSE )
then
370 if( s->
data <> NULL )
then
371 deallocate( s->
data )
374 s->
data =
allocate( (newsize + 1) * charsize )
376 if( s->
data = NULL )
then
377 s->
data =
xallocate( (chars + 1) * charsize )
384 s->
data =
reallocate( p, (newsize + 1) * charsize )
386 if( s->
data = NULL )
then