mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-18 06:38:29 -04:00
AP_Common: added return to ExpandingString append
This commit is contained in:
parent
e055165eb8
commit
3fb280ff50
@ -84,16 +84,19 @@ void ExpandingString::printf(const char *format, ...)
|
|||||||
/*
|
/*
|
||||||
print into the buffer, expanding if needed
|
print into the buffer, expanding if needed
|
||||||
*/
|
*/
|
||||||
void ExpandingString::append(const char *s, uint32_t len)
|
bool ExpandingString::append(const char *s, uint32_t len)
|
||||||
{
|
{
|
||||||
if (allocation_failed) {
|
if (allocation_failed) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (buflen - used < len && !expand(len)) {
|
if (buflen - used < len && !expand(len)) {
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
if (s != nullptr) {
|
||||||
|
memcpy(&buf[used], s, len);
|
||||||
}
|
}
|
||||||
memcpy(&buf[used], s, len);
|
|
||||||
used += len;
|
used += len;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpandingString::~ExpandingString()
|
ExpandingString::~ExpandingString()
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
// print into the string
|
// print into the string
|
||||||
void printf(const char *format, ...) FMT_PRINTF(2,3);
|
void printf(const char *format, ...) FMT_PRINTF(2,3);
|
||||||
|
|
||||||
// append data to the string
|
// append data to the string. s can be null for zero fill
|
||||||
void append(const char *s, uint32_t len);
|
bool append(const char *s, uint32_t len);
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
~ExpandingString();
|
~ExpandingString();
|
||||||
|
Loading…
Reference in New Issue
Block a user