mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Switch Frame::SetElement() to use IntrusivePtr
This commit is contained in:
parent
1c617c4f7a
commit
e9e2e388f8
5 changed files with 78 additions and 60 deletions
39
src/Frame.h
39
src/Frame.h
|
@ -45,16 +45,14 @@ public:
|
|||
Val* NthElement(int n) const { return frame[n].get(); }
|
||||
|
||||
/**
|
||||
* Sets the element at index *n* of the underlying array
|
||||
* to *v*.
|
||||
*
|
||||
* Sets the element at index *n* of the underlying array to *v*.
|
||||
* @param n the index to set
|
||||
* @param v the value to set it to
|
||||
* @param weak_ref whether the frame owns the value and should unref
|
||||
* it upon destruction. Used to break circular references between
|
||||
* lambda functions and closure frames.
|
||||
*/
|
||||
void SetElement(int n, Val* v, bool weak_ref = false);
|
||||
void SetElement(int n, IntrusivePtr<Val> v);
|
||||
|
||||
[[deprecated("Remove in v4.1. Pass IntrusivePtr instead.")]]
|
||||
void SetElement(int n, Val* v);
|
||||
|
||||
/**
|
||||
* Associates *id* and *v* in the frame. Future lookups of
|
||||
|
@ -63,7 +61,7 @@ public:
|
|||
* @param id the ID to associate
|
||||
* @param v the value to associate it with
|
||||
*/
|
||||
void SetElement(const ID* id, Val* v);
|
||||
void SetElement(const ID* id, IntrusivePtr<Val> v);
|
||||
|
||||
/**
|
||||
* Gets the value associated with *id* and returns it. Returns
|
||||
|
@ -76,8 +74,7 @@ public:
|
|||
|
||||
/**
|
||||
* Resets all of the indexes from [*startIdx, frame_size) in
|
||||
* the Frame. Unrefs all of the values in reset indexes.
|
||||
*
|
||||
* the Frame.
|
||||
* @param the first index to unref.
|
||||
*/
|
||||
void Reset(int startIdx);
|
||||
|
@ -232,9 +229,27 @@ private:
|
|||
using OffsetMap = std::unordered_map<std::string, int>;
|
||||
|
||||
/**
|
||||
* Unrefs the value at offset 'n' frame unless it's a weak reference.
|
||||
* Sets the element at index *n* of the underlying array to *v*, but does
|
||||
* not take ownership of a reference count to it. This method is used to
|
||||
* break circular references between lambda functions and closure frames.
|
||||
* @param n the index to set
|
||||
* @param v the value to set it to (caller has not Ref'd and Frame will
|
||||
* not Unref it)
|
||||
*/
|
||||
void UnrefElement(int n);
|
||||
void SetElementWeak(int n, Val* v);
|
||||
|
||||
/**
|
||||
* Clone an element at an offset into other frame if not equal to a given
|
||||
* function (in that case just assigna weak reference). Used to break
|
||||
* circular references between lambda functions and closure frames.
|
||||
*/
|
||||
void CloneNonFuncElement(int offset, BroFunc* func, Frame* other) const;
|
||||
|
||||
/**
|
||||
* Resets the value at offset 'n' frame (by decrementing reference
|
||||
* count if not a weak reference).
|
||||
*/
|
||||
void ClearElement(int n);
|
||||
|
||||
/** Have we captured this id? */
|
||||
bool IsOuterID(const ID* in) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue