mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 03:28:19 +00:00
change functions for ZVal type management to static members
This commit is contained in:
parent
1e316c05c9
commit
efe40204e0
5 changed files with 58 additions and 59 deletions
36
src/ZVal.h
36
src/ZVal.h
|
@ -79,6 +79,24 @@ union ZVal {
|
|||
|
||||
Obj* ManagedVal() const { return managed_val; }
|
||||
|
||||
// True if a given type is one for which we manage the associated
|
||||
// memory internally.
|
||||
static bool IsManagedType(const TypePtr& t);
|
||||
|
||||
// Deletes a managed value. Caller needs to ensure that the ZVal
|
||||
// indeed holds such.
|
||||
static void DeleteManagedType(ZVal& v)
|
||||
{
|
||||
Unref(v.ManagedVal());
|
||||
}
|
||||
|
||||
// Deletes a possibly-managed value.
|
||||
static void DeleteIfManaged(ZVal& v, const TypePtr& t)
|
||||
{
|
||||
if ( IsManagedType(t) )
|
||||
DeleteManagedType(v);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class RecordVal;
|
||||
friend class VectorVal;
|
||||
|
@ -124,22 +142,4 @@ private:
|
|||
static bool zval_was_nil;
|
||||
};
|
||||
|
||||
// True if a given type is one for which we manage the associated
|
||||
// memory internally.
|
||||
bool IsManagedType(const TypePtr& t);
|
||||
|
||||
// Deletes a managed value. Caller needs to ensure that the ZVal
|
||||
// indeed holds such.
|
||||
inline void DeleteManagedType(ZVal& v)
|
||||
{
|
||||
Unref(v.ManagedVal());
|
||||
}
|
||||
|
||||
// Deletes a possibly-managed value.
|
||||
inline void DeleteIfManaged(ZVal& v, const TypePtr& t)
|
||||
{
|
||||
if ( IsManagedType(t) )
|
||||
DeleteManagedType(v);
|
||||
}
|
||||
|
||||
} // zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue