Skip to content

Commit

Permalink
[core] Applied clang-format on cache.h and cache.cpp.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Aug 4, 2024
1 parent 968c9f9 commit 77eed81
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 225 deletions.
93 changes: 46 additions & 47 deletions srtcore/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ written by
Yunhong Gu, last updated 05/05/2009
*****************************************************************************/


#include "platform_sys.h"

#include <cstring>
Expand All @@ -49,70 +48,70 @@ using namespace std;

srt::CInfoBlock& srt::CInfoBlock::copyFrom(const CInfoBlock& obj)
{
std::copy(obj.m_piIP, obj.m_piIP + 4, m_piIP);
m_iIPversion = obj.m_iIPversion;
m_ullTimeStamp = obj.m_ullTimeStamp;
m_iSRTT = obj.m_iSRTT;
m_iBandwidth = obj.m_iBandwidth;
m_iLossRate = obj.m_iLossRate;
m_iReorderDistance = obj.m_iReorderDistance;
m_dInterval = obj.m_dInterval;
m_dCWnd = obj.m_dCWnd;

return *this;
std::copy(obj.m_piIP, obj.m_piIP + 4, m_piIP);
m_iIPversion = obj.m_iIPversion;
m_ullTimeStamp = obj.m_ullTimeStamp;
m_iSRTT = obj.m_iSRTT;
m_iBandwidth = obj.m_iBandwidth;
m_iLossRate = obj.m_iLossRate;
m_iReorderDistance = obj.m_iReorderDistance;
m_dInterval = obj.m_dInterval;
m_dCWnd = obj.m_dCWnd;

return *this;
}

bool srt::CInfoBlock::operator==(const CInfoBlock& obj) const
{
if (m_iIPversion != obj.m_iIPversion)
return false;
if (m_iIPversion != obj.m_iIPversion)
return false;

else if (m_iIPversion == AF_INET)
return (m_piIP[0] == obj.m_piIP[0]);
else if (m_iIPversion == AF_INET)
return (m_piIP[0] == obj.m_piIP[0]);

for (int i = 0; i < 4; ++ i)
{
if (m_piIP[i] != obj.m_piIP[i])
return false;
}
for (int i = 0; i < 4; ++i)
{
if (m_piIP[i] != obj.m_piIP[i])
return false;
}

return true;
return true;
}

srt::CInfoBlock* srt::CInfoBlock::clone()
{
CInfoBlock* obj = new CInfoBlock;

std::copy(m_piIP, m_piIP + 4, obj->m_piIP);
obj->m_iIPversion = m_iIPversion;
obj->m_ullTimeStamp = m_ullTimeStamp;
obj->m_iSRTT = m_iSRTT;
obj->m_iBandwidth = m_iBandwidth;
obj->m_iLossRate = m_iLossRate;
obj->m_iReorderDistance = m_iReorderDistance;
obj->m_dInterval = m_dInterval;
obj->m_dCWnd = m_dCWnd;

return obj;
CInfoBlock* obj = new CInfoBlock;

std::copy(m_piIP, m_piIP + 4, obj->m_piIP);
obj->m_iIPversion = m_iIPversion;
obj->m_ullTimeStamp = m_ullTimeStamp;
obj->m_iSRTT = m_iSRTT;
obj->m_iBandwidth = m_iBandwidth;
obj->m_iLossRate = m_iLossRate;
obj->m_iReorderDistance = m_iReorderDistance;
obj->m_dInterval = m_dInterval;
obj->m_dCWnd = m_dCWnd;

return obj;
}

int srt::CInfoBlock::getKey()
{
if (m_iIPversion == AF_INET)
return m_piIP[0];
if (m_iIPversion == AF_INET)
return m_piIP[0];

return m_piIP[0] + m_piIP[1] + m_piIP[2] + m_piIP[3];
return m_piIP[0] + m_piIP[1] + m_piIP[2] + m_piIP[3];
}

void srt::CInfoBlock::convert(const sockaddr_any& addr, uint32_t aw_ip[4])
{
if (addr.family() == AF_INET)
{
aw_ip[0] = addr.sin.sin_addr.s_addr;
aw_ip[1] = aw_ip[2] = aw_ip[3] = 0;
}
else
{
memcpy((aw_ip), addr.sin6.sin6_addr.s6_addr, sizeof addr.sin6.sin6_addr.s6_addr);
}
if (addr.family() == AF_INET)
{
aw_ip[0] = addr.sin.sin_addr.s_addr;
aw_ip[1] = aw_ip[2] = aw_ip[3] = 0;
}
else
{
memcpy((aw_ip), addr.sin6.sin6_addr.s6_addr, sizeof addr.sin6.sin6_addr.s6_addr);
}
}
Loading

0 comments on commit 77eed81

Please sign in to comment.