Browse Source

AP_Common: added return to ExpandingString append

zr-v5.1
Andrew Tridgell 4 years ago
parent
commit
3fb280ff50
  1. 11
      libraries/AP_Common/ExpandingString.cpp
  2. 4
      libraries/AP_Common/ExpandingString.h

11
libraries/AP_Common/ExpandingString.cpp

@ -84,16 +84,19 @@ void ExpandingString::printf(const char *format, ...) @@ -84,16 +84,19 @@ void ExpandingString::printf(const char *format, ...)
/*
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) {
return;
return false;
}
if (buflen - used < len && !expand(len)) {
return;
return false;
}
if (s != nullptr) {
memcpy(&buf[used], s, len);
}
memcpy(&buf[used], s, len);
used += len;
return true;
}
ExpandingString::~ExpandingString()

4
libraries/AP_Common/ExpandingString.h

@ -36,8 +36,8 @@ public: @@ -36,8 +36,8 @@ public:
// print into the string
void printf(const char *format, ...) FMT_PRINTF(2,3);
// append data to the string
void append(const char *s, uint32_t len);
// append data to the string. s can be null for zero fill
bool append(const char *s, uint32_t len);
// destructor
~ExpandingString();

Loading…
Cancel
Save