mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Fix unsafe and inefficient uses of copy_string
Add a new overload to `copy_string` that takes the input characters plus size. The new overload avoids inefficient scanning of the input for the null terminator in cases where we know the size beforehand. Furthermore, this overload *must* be used when dealing with input character sequences that may have no null terminator, e.g., when the input is from a `std::string_view` object.
This commit is contained in:
parent
4eb1b71d1b
commit
cebb85b1e8
25 changed files with 85 additions and 56 deletions
|
@ -330,6 +330,7 @@ std::vector<std::string>* tokenize_string(std::string_view input, std::string_vi
|
|||
|
||||
std::vector<std::string_view> tokenize_string(std::string_view input, const char delim) noexcept;
|
||||
|
||||
extern char* copy_string(const char* str, size_t len);
|
||||
extern char* copy_string(const char* s);
|
||||
extern bool streq(const char* s1, const char* s2);
|
||||
extern bool starts_with(std::string_view s, std::string_view beginning);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue