mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-12 21:22:22 +00:00
Make PStruct::AddField() check for duplicates
- PStruct::AddField() now checks the symbol table for a symbol of the same name before adding a new field. If the name is in use, it returns NULL.
This commit is contained in:
parent
27ddaad7ca
commit
0d1973a659
2 changed files with 9 additions and 4 deletions
|
@ -1414,11 +1414,12 @@ PStruct::PStruct(FName name, DObject *outer)
|
|||
//
|
||||
// PStruct :: AddField
|
||||
//
|
||||
// Appends a new field to the end of a struct.
|
||||
// Appends a new field to the end of a struct. Returns either the new field
|
||||
// or NULL if a symbol by that name already exists.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
PField *PStruct::AddField(FName name, PType *type)
|
||||
PField *PStruct::AddField(FName name, PType *type, DWORD flags)
|
||||
{
|
||||
PField *field = new PField(name, type);
|
||||
|
||||
|
@ -1432,8 +1433,12 @@ PField *PStruct::AddField(FName name, PType *type)
|
|||
// its fields.
|
||||
Align = MAX(Align, type->Align);
|
||||
|
||||
if (Symbols.AddSymbol(field) == NULL)
|
||||
{ // name is already in use
|
||||
delete field;
|
||||
return NULL;
|
||||
}
|
||||
Fields.Push(field);
|
||||
Symbols.AddSymbol(field);
|
||||
|
||||
return field;
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ public:
|
|||
TArray<PField *> Fields;
|
||||
PSymbolTable Symbols;
|
||||
|
||||
PField *AddField(FName name, PType *type);
|
||||
PField *AddField(FName name, PType *type, DWORD flags=0);
|
||||
|
||||
size_t PropagateMark();
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue