F´ Flight Software - C/C++ Documentation
NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
j
l
m
o
p
r
s
t
u
v
w
Variables
b
c
f
g
k
l
m
o
p
r
s
t
u
w
z
Typedefs
a
b
c
d
e
f
g
h
i
l
n
o
p
r
s
t
u
v
w
Enumerations
Enumerator
a
b
f
h
i
k
n
o
p
s
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
a
b
c
e
f
i
m
r
s
t
w
Enumerations
b
c
d
f
g
h
m
o
q
r
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Related Symbols
:
a
b
c
d
f
g
h
l
p
q
r
s
t
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Functions
f
g
i
m
p
r
s
t
u
Variables
_
b
c
f
g
i
l
p
r
s
w
Typedefs
a
b
c
e
f
i
n
p
s
t
u
Enumerations
Enumerator
a
b
c
f
g
h
p
r
s
t
Macros
_
a
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
►
F´ Flight Software - C/C++ Documentation
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
StringUtils.cpp
Go to the documentation of this file.
1
#include "
StringUtils.hpp
"
2
#include <
Fw/Types/Assert.hpp
>
3
#include <cstring>
4
5
char
*
Fw::StringUtils::string_copy
(
char
* destination,
const
char
* source, U32 num) {
6
// Handle self-copy and 0 bytes copy
7
if
(destination == source || num == 0) {
8
return
destination;
9
}
10
11
// Copying an overlapping range is undefined
12
U32 source_len =
string_length
(source, num) + 1;
13
FW_ASSERT
(source + source_len <= destination || destination + num <= source);
14
15
char
* returned = strncpy(destination, source, num);
16
destination[num - 1] =
'\0'
;
17
return
returned;
18
}
5
char
*
Fw::StringUtils::string_copy
(
char
* destination,
const
char
* source, U32 num) {
…
}
19
20
U32
Fw::StringUtils::string_length
(
const
CHAR
* source, U32 max_len) {
21
U32 length = 0;
22
FW_ASSERT
(source !=
nullptr
);
23
for
(length = 0; length < max_len; length++) {
24
if
(source[length] ==
'\0'
) {
25
break
;
26
}
27
}
28
return
length;
29
}
20
U32
Fw::StringUtils::string_length
(
const
CHAR
* source, U32 max_len) {
…
}
Assert.hpp
FW_ASSERT
#define FW_ASSERT(...)
Definition
Assert.hpp:7
CHAR
char CHAR
Definition
BasicTypes.h:28
StringUtils.hpp
Fw::StringUtils::string_copy
char * string_copy(char *destination, const char *source, U32 num)
copy string with null-termination guaranteed
Definition
StringUtils.cpp:5
Fw::StringUtils::string_length
U32 string_length(const CHAR *source, U32 max_len)
get the length of the source string or max_len if the string is longer than max_len.
Definition
StringUtils.cpp:20
Fw
Types
StringUtils.cpp
Generated by
1.10.0