Skip to content

Commit 814263b

Browse files
committed
GDBServer: Mostly rewrite handlers and fix undefined behaviour
Remove all heap allocations. Remove copies.
1 parent 2f5855a commit 814263b

2 files changed

Lines changed: 184 additions & 171 deletions

File tree

src/common/string_util.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,19 @@ void ReplaceAll(std::string* subject, const char search, const char replacement)
415415
/// Parses an assignment string (Key = Value) into its two components.
416416
bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value);
417417

418+
/// Helper for tokenizing strings.
419+
ALWAYS_INLINE std::optional<std::string_view> GetNextToken(std::string_view& caret, char separator)
420+
{
421+
std::optional<std::string_view> ret;
422+
const std::string_view::size_type pos = caret.find(separator);
423+
if (pos != std::string_view::npos)
424+
{
425+
ret = caret.substr(0, pos);
426+
caret = caret.substr(pos + 1);
427+
}
428+
return ret;
429+
}
430+
418431
/// Unicode replacement character.
419432
static constexpr char32_t UNICODE_REPLACEMENT_CHARACTER = 0xFFFD;
420433

0 commit comments

Comments
 (0)