Skip to content

Commit

Permalink
change style of pointer creation due to read access violation with pr…
Browse files Browse the repository at this point in the history
…evious way
  • Loading branch information
nam20485 committed Oct 11, 2023
1 parent 3899cbe commit ce75fb7
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions OdbDesignLib/EdaDataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ namespace Odb::Lib::FileModel::Design

std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord> EdaDataFile::NetRecord::SubnetRecord::to_protobuf() const
{
//auto pSubnetRecordMessage = std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord>();
std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord> pSubnetRecordMessage(new odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord);

std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord> pSubnetRecordMessage(new odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord);
pSubnetRecordMessage->set_type((odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord::Type) type);

if (type == Type::Toeprint)
{
pSubnetRecordMessage->set_componentnumber(componentNumber);
Expand All @@ -63,7 +60,6 @@ namespace Odb::Lib::FileModel::Design
auto pFeatureIdRecordMessage = pSubnetRecordMessage->add_featureidrecords();
pFeatureIdRecordMessage->CopyFrom(*featureIdRecord->to_protobuf());
}

return pSubnetRecordMessage;
}

Expand All @@ -79,8 +75,7 @@ namespace Odb::Lib::FileModel::Design

std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord> EdaDataFile::NetRecord::to_protobuf() const
{
auto pNetRecordMessage = std::make_unique<odbdesign::proto::EdaDataFile::NetRecord>();

std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord> pNetRecordMessage(new odbdesign::proto::EdaDataFile::NetRecord);
pNetRecordMessage->set_name(name);
pNetRecordMessage->set_attributesidstring(attributesIdString);
pNetRecordMessage->set_index(index);
Expand All @@ -95,8 +90,7 @@ namespace Odb::Lib::FileModel::Design
{
auto pSubnetRecordMessage = pNetRecordMessage->add_subnetrecords();
pSubnetRecordMessage->CopyFrom(*subnetRecord->to_protobuf());
}

}
return pNetRecordMessage;
}

Expand All @@ -108,12 +102,10 @@ namespace Odb::Lib::FileModel::Design
std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord::FeatureIdRecord>
EdaDataFile::NetRecord::SubnetRecord::FeatureIdRecord::to_protobuf() const
{
auto pFeatureIdRecordMessage = std::make_unique<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord::FeatureIdRecord>();

std::unique_ptr<odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord::FeatureIdRecord> pFeatureIdRecordMessage(new odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord::FeatureIdRecord);
pFeatureIdRecordMessage->set_type((odbdesign::proto::EdaDataFile::NetRecord::SubnetRecord::FeatureIdRecord::Type) type);
pFeatureIdRecordMessage->set_layernumber(layerNumber);
pFeatureIdRecordMessage->set_featurenumber(featureNumber);

return pFeatureIdRecordMessage;
}

Expand Down Expand Up @@ -159,8 +151,7 @@ namespace Odb::Lib::FileModel::Design

std::unique_ptr<odbdesign::proto::EdaDataFile> EdaDataFile::to_protobuf() const
{
std::unique_ptr<odbdesign::proto::EdaDataFile> pEdaDataFileMessage(new odbdesign::proto::EdaDataFile);

std::unique_ptr<odbdesign::proto::EdaDataFile> pEdaDataFileMessage(new odbdesign::proto::EdaDataFile);
pEdaDataFileMessage->set_path(m_path.string());
pEdaDataFileMessage->set_units(m_units);
pEdaDataFileMessage->set_source(m_source);
Expand Down Expand Up @@ -193,8 +184,7 @@ namespace Odb::Lib::FileModel::Design
for (const auto& kvPackageRecord : m_packageRecordsByName)
{
(*pEdaDataFileMessage->mutable_packagerecordsbyname())[kvPackageRecord.first] = *kvPackageRecord.second->to_protobuf();
}

}
return pEdaDataFileMessage;
}

Expand Down Expand Up @@ -741,7 +731,7 @@ namespace Odb::Lib::FileModel::Design
std::unique_ptr<odbdesign::proto::EdaDataFile::PropertyRecord>
EdaDataFile::PropertyRecord::to_protobuf() const
{
auto pPropertyRecordMessage = std::make_unique<odbdesign::proto::EdaDataFile::PropertyRecord>();
std::unique_ptr<odbdesign::proto::EdaDataFile::PropertyRecord> pPropertyRecordMessage(new odbdesign::proto::EdaDataFile::PropertyRecord);
pPropertyRecordMessage->set_name(name);
pPropertyRecordMessage->set_value(value);
for (const auto& f : floatValues)
Expand All @@ -758,8 +748,8 @@ namespace Odb::Lib::FileModel::Design
// Inherited via IProtoBuffable
std::unique_ptr<odbdesign::proto::EdaDataFile::PackageRecord>
EdaDataFile::PackageRecord::to_protobuf() const
{
auto pPackageRecordMessage = std::make_unique<odbdesign::proto::EdaDataFile::PackageRecord>();
{
std::unique_ptr<odbdesign::proto::EdaDataFile::PackageRecord> pPackageRecordMessage(new odbdesign::proto::EdaDataFile::PackageRecord);
pPackageRecordMessage->set_name(name);
pPackageRecordMessage->set_pitch(pitch);
pPackageRecordMessage->set_xmin(xMin);
Expand Down Expand Up @@ -792,7 +782,7 @@ namespace Odb::Lib::FileModel::Design
std::unique_ptr<odbdesign::proto::EdaDataFile::PackageRecord::PinRecord>
EdaDataFile::PackageRecord::PinRecord::to_protobuf() const
{
auto pPinRecordMessage = std::make_unique<odbdesign::proto::EdaDataFile::PackageRecord::PinRecord>();
std::unique_ptr<odbdesign::proto::EdaDataFile::PackageRecord::PinRecord> pPinRecordMessage(new odbdesign::proto::EdaDataFile::PackageRecord::PinRecord);
pPinRecordMessage->set_name(name);
pPinRecordMessage->set_type((odbdesign::proto::EdaDataFile::PackageRecord::PinRecord::Type)type);
pPinRecordMessage->set_xcenter(xCenter);
Expand Down

0 comments on commit ce75fb7

Please sign in to comment.