mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
... porting over memory management for assignment to record fields
This commit is contained in:
parent
9468b81a7b
commit
1447736b35
4 changed files with 60 additions and 19 deletions
20
src/Type.cc
20
src/Type.cc
|
@ -826,7 +826,16 @@ void TypeDecl::DescribeReST(ODesc* d, bool roles_only) const
|
|||
RecordType::RecordType(type_decl_list* arg_types) : Type(TYPE_RECORD)
|
||||
{
|
||||
types = arg_types;
|
||||
num_fields = types ? types->length() : 0;
|
||||
|
||||
if ( types )
|
||||
{
|
||||
num_fields = types->length();
|
||||
|
||||
loop_over_list(*types, i)
|
||||
AddField(i, (*types)[i]);
|
||||
}
|
||||
else
|
||||
num_fields = 0;
|
||||
}
|
||||
|
||||
// in this case the clone is actually not so shallow, since
|
||||
|
@ -850,6 +859,13 @@ RecordType::~RecordType()
|
|||
}
|
||||
}
|
||||
|
||||
void RecordType::AddField(unsigned int field, const TypeDecl* td)
|
||||
{
|
||||
ASSERT(field == managed_fields.size());
|
||||
|
||||
managed_fields.push_back(IsManagedType(td->type));
|
||||
}
|
||||
|
||||
bool RecordType::HasField(const char* field) const
|
||||
{
|
||||
return FieldOffset(field) >= 0;
|
||||
|
@ -1023,7 +1039,9 @@ const char* RecordType::AddFields(const type_decl_list& others,
|
|||
td->attrs->AddAttr(make_intrusive<detail::Attr>(detail::ATTR_LOG));
|
||||
}
|
||||
|
||||
int field = types->size();
|
||||
types->push_back(td);
|
||||
AddField(field, td);
|
||||
}
|
||||
|
||||
num_fields = types->length();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue