FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
str_concat.c
Go to the documentation of this file.
1
/* string concatenation function */
2
3
#include "
fb.h
"
4
5
static
__inline__
void
fb_hStrConcat
6
(
7
char
*dst,
8
const
char
*str1,
9
ssize_t len1,
10
const
char
*str2,
11
ssize_t len2
12
)
13
{
14
dst = (
char
*)
FB_MEMCPYX
( dst, str1, len1 );
15
dst = (
char
*)
FB_MEMCPYX
( dst, str2, len2 );
16
*dst =
'\0'
;
17
}
18
19
FBCALL
FBSTRING
*
fb_StrConcat
20
(
21
FBSTRING
*dst,
22
void
*str1,
23
ssize_t str1_size,
24
void
*str2,
25
ssize_t str2_size
26
)
27
{
28
const
char
*str1_ptr, *str2_ptr;
29
ssize_t str1_len, str2_len;
30
31
FB_STRSETUP_FIX
( str1, str1_size, str1_ptr, str1_len );
32
33
FB_STRSETUP_FIX
( str2, str2_size, str2_ptr, str2_len );
34
35
/* NULL? */
36
if
( str1_len+str2_len == 0 )
37
{
38
fb_StrDelete
( dst );
39
}
40
else
41
{
42
/* alloc temp string */
43
dst =
fb_hStrAllocTemp
( dst, str1_len+str2_len );
44
DBG_ASSERT
( dst );
45
46
/* do the concatenation */
47
fb_hStrConcat
( dst->
data
, str1_ptr, str1_len, str2_ptr, str2_len );
48
}
49
50
FB_STRLOCK
();
51
52
/* delete temps? */
53
if
( str1_size == -1 )
54
fb_hStrDelTemp_NoLock
( (
FBSTRING
*)str1 );
55
if
( str2_size == -1 )
56
fb_hStrDelTemp_NoLock
( (
FBSTRING
*)str2 );
57
58
FB_STRUNLOCK
();
59
60
return
dst;
61
}
62
rtlib
str_concat.c
Generated on Thu Jan 23 2014 19:40:12 for FreeBASIC by
1.8.4