Skip to content

Commit

Permalink
Calling a new Reset() method on TargetVideoPlayerInfo instead of mems…
Browse files Browse the repository at this point in the history
…etting its objects to zeroes
  • Loading branch information
sharadb-amazon committed Apr 4, 2023
1 parent e6a1ccb commit 21b9097
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class TargetVideoPlayerInfo
bool operator==(const TargetVideoPlayerInfo & other) { return this->mNodeId == other.mNodeId; }

bool IsInitialized() { return mInitialized; }
void Reset();
uint16_t GetVendorId() const { return mVendorId; }
uint16_t GetProductId() const { return mProductId; }
chip::DeviceTypeId GetDeviceType() const { return mDeviceType; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ void PersistenceManager::OnFabricRemoved(const FabricTable & fabricTable, Fabric
}
}

// memset cachedVideoPlayers[indexToDelete] to zeroes
memset(&cachedVideoPlayers[indexToDelete], 0, sizeof(cachedVideoPlayers[indexToDelete]));
// Reset cachedVideoPlayers[indexToDelete]
cachedVideoPlayers[indexToDelete].Reset();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ CHIP_ERROR TargetVideoPlayerInfo::Initialize(NodeId nodeId, FabricIndex fabricIn
return CHIP_NO_ERROR;
}

void TargetVideoPlayerInfo::Reset()
{
ChipLogProgress(NotSpecified, "TargetVideoPlayerInfo Reset() called");
mInitialized = false;
mNodeId = 0;
mFabricIndex = 0;
mVendorId = 0;
mProductId = 0;
mDeviceType = 0;
memset(mDeviceName, '\0', sizeof(mDeviceName));
memset(mHostName, '\0', sizeof(mHostName));
mDeviceProxy = nullptr;
for (auto & endpointInfo : mEndpoints)
{
endpointInfo.Reset();
}
for (size_t i = 0; i < mNumIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++)
{
mIpAddress[i] = chip::Inet::IPAddress();
}
mNumIPs = 0;
}

CHIP_ERROR TargetVideoPlayerInfo::FindOrEstablishCASESession(std::function<void(TargetVideoPlayerInfo *)> onConnectionSuccess,
std::function<void(CHIP_ERROR)> onConnectionFailure)
{
Expand Down

0 comments on commit 21b9097

Please sign in to comment.