Commit graph

27 commits

Author SHA1 Message Date
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Tomer Lev
12494aac45 Fixed initial CR comments 2022-11-09 18:54:42 +02:00
Tim Wojtulewicz
77c555a3a8 Fixing some issues from rebasing 2022-11-09 18:16:13 +02:00
Elad Solomon
44df3087d6 Fixed intrusive ptr conversion to Obj* 2022-11-09 18:15:34 +02:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Dominik Charousset
2f19c89189 Improve assignment operators for IntrusivePtr
Fixes Coverity finding 1367523 (Missing move assignment operator).
2021-06-06 15:34:24 +02:00
Jon Siwek
583310f6dd Add std::hash specialization for IntrusivePtr 2021-04-03 10:08:02 -07:00
Jon Siwek
cffc8fa13c Move IntrusivePtr relational operators to zeek namespace
Otherwise some cases relying on argument-dependent lookup (ADL) fail.
2021-04-03 09:46:22 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
812ac5536d Tag the end of some namespaces for consistency 2020-08-20 16:11:46 -07:00
Tim Wojtulewicz
02cef05f93 Rename BroObj to Obj 2020-07-02 16:15:01 -07:00
Tim Wojtulewicz
9364e6a5b7 Move IntrusivePtr and utility methods to the zeek namespace 2020-06-30 20:19:12 -07:00
Jon Siwek
6a1e4d61d1 Add cast_intrusive() and make use of it in two spots 2020-05-14 17:18:00 -07:00
Jon Siwek
597407a708 Merge branch 'refactor' of https://github.com/MaxKellermann/zeek
- Minor code style/format tweaks in merge

* 'refactor' of https://github.com/MaxKellermann/zeek:
  IntrusivePtr: overload std::swap()
  IntrusivePtr: eliminate setPtr()
  IntrusivePtr: optimize release() using std::exchange()
  Expr: remove unused default constructors and `friend` declarations
  Expr: remove useless override
  Type: don't pass reference to pointer to MatchesIndex()
  Expr: don't pass reference to pointer to check_and_promote*()
  ID: remove unused default constructor
  Scope: simplify PList access, use pop_back() and back()
  List: add method empty()
2020-02-26 10:07:31 -08:00
Max Kellermann
5ed69edb7e IntrusivePtr: overload std::swap() 2020-02-25 21:05:59 +01:00
Max Kellermann
4dbc224e21 IntrusivePtr: eliminate setPtr()
There are only two call sites, and those hard-code the `add_ref`
parameter.
2020-02-25 21:05:53 +01:00
Max Kellermann
6f3e9d2c4c IntrusivePtr: optimize release() using std::exchange() 2020-02-25 21:05:42 +01:00
Max Kellermann
31b3a56740 IntrusivePtr: replace the "add_ref" parameter with tag structs
Using a runtime parameter is obscure and error-prone.  Avoiding
error-prone code and getting reference counting right is the whole
point of this class.
2020-02-20 15:56:50 +01:00
Max Kellermann
7c0863dccf IntrusivePtr: remove reset(), nobody uses it
This method mimicks std::unique_ptr::reset(), but adds an obscure
"add_ref" parameter which is error prone.  Since nobody uses this
method, and this method is all about dealing with raw pointers which
we shouldn't be doing, let's remove it.
2020-02-20 15:56:48 +01:00
Max Kellermann
98b27a2ae8 IntrusivePtr: remove ordering operators
These violate the C++ standard because comparing pointers to unrelated
objects is undefined behavior.
2020-02-20 15:56:32 +01:00
Max Kellermann
08128b244f IntrusivePtr: rename detach() to release()
Follow the C++ standard library conventions (here: `std::unique_ptr`).
2020-02-20 08:58:21 +01:00
Max Kellermann
edb93d1733 IntrusivePtr: move nullptr initializer to field declaration
This allows "defaulting" the default constructor, and guarantees that
all constructors really initialize the field to a legal value.
2020-02-20 08:58:21 +01:00
Jon Siwek
5cece12333 Merge remote-tracking branch 'origin/topic/neverlord/intrusive-ptr'
* origin/topic/neverlord/intrusive-ptr:
  Add API documentation to IntrusivePtr
  Rename make{ Counted => _intrusive }
  Remove braces around single return statements
  Integrate review feedback
  Add and use new IntrusivePt type in Zeek
2019-11-05 09:56:07 -08:00
Dominik Charousset
fadaa40e04 Add API documentation to IntrusivePtr 2019-10-30 21:02:06 +01:00
Dominik Charousset
054a4f4612 Rename make{ Counted => _intrusive } 2019-10-30 20:27:57 +01:00
Dominik Charousset
72e15fe4d4 Integrate review feedback 2019-10-29 21:24:56 +01:00
Dominik Charousset
0f41b063b2 Add and use new IntrusivePt type in Zeek
Manual memory management via Ref/Unref is verbose and prone to error. An
intrusive smart pointer automates the reference counting, makes code
more robust (in particular w.r.t. to exceptions) and reduces boilerplate
code. A big benefit of the intrusive smart pointers for Zeek is that
they can co-exist with the manual memory management. Rather than having
to port the entire code base at once, we can migrate components
one-by-one. In this first step, we add the new template
`IntrusivePtr<T>` and start using it in the Broker Manager. This makes
the previous `unref_guard` obsolete.
2019-10-29 16:49:27 +01:00