Simplify some copy_string() usages in threading::Field

This commit is contained in:
Jon Siwek 2021-03-05 17:37:03 -08:00
parent ff90236df3
commit 6946cffde2
3 changed files with 17 additions and 7 deletions

10
CHANGES
View file

@ -1,4 +1,14 @@
4.1.0-dev.284 | 2021-03-05 17:37:03 -0800
* Simplify some copy_string() usages in threading::Field (Jon Siwek, Corelight)
* Use const-reference in plugin::Manager::MetaHookPost for minor performance gain (Tim Wojtulewicz, Corelight)
* Fix missing assigmnent operator/copy constructor pairings reported by LGTM (Tim Wojtulewicz, Corelight)
* Fix variable shadowing issues reported by LGTM (Tim Wojtulewicz, Corelight)
4.1.0-dev.277 | 2021-03-05 16:14:23 -0800 4.1.0-dev.277 | 2021-03-05 16:14:23 -0800
* Avoid reporting paths repeatedly in zeek-config --include_dir (Christian Kreibich, Corelight) * Avoid reporting paths repeatedly in zeek-config --include_dir (Christian Kreibich, Corelight)

View file

@ -1 +1 @@
4.1.0-dev.277 4.1.0-dev.284

View file

@ -29,16 +29,16 @@ struct Field {
* Constructor. * Constructor.
*/ */
Field(const char* name, const char* secondary_name, TypeTag type, TypeTag subtype, bool optional) Field(const char* name, const char* secondary_name, TypeTag type, TypeTag subtype, bool optional)
: name(name ? util::copy_string(name) : nullptr), : name(util::copy_string(name)),
secondary_name(secondary_name ? util::copy_string(secondary_name) : nullptr), secondary_name(util::copy_string(secondary_name)),
type(type), subtype(subtype), optional(optional) { } type(type), subtype(subtype), optional(optional) { }
/** /**
* Copy constructor. * Copy constructor.
*/ */
Field(const Field& other) Field(const Field& other)
: name(other.name ? util::copy_string(other.name) : nullptr), : name(util::copy_string(other.name)),
secondary_name(other.secondary_name ? util::copy_string(other.secondary_name) : nullptr), secondary_name(util::copy_string(other.secondary_name)),
type(other.type), subtype(other.subtype), optional(other.optional) { } type(other.type), subtype(other.subtype), optional(other.optional) { }
~Field() ~Field()
@ -53,8 +53,8 @@ struct Field {
{ {
delete [] name; delete [] name;
delete [] secondary_name; delete [] secondary_name;
name = other.name ? util::copy_string(other.name) : nullptr; name = util::copy_string(other.name);
secondary_name = other.secondary_name ? util::copy_string(other.secondary_name) : nullptr; secondary_name = util::copy_string(other.secondary_name);
type = other.type; type = other.type;
subtype = other.subtype; subtype = other.subtype;
optional = other.optional; optional = other.optional;