1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-26 20:24:38 +01:00

I apparently still suck at C++ memory management

This commit is contained in:
Grishka 2018-12-12 03:28:11 +03:00
parent 7f54b9109c
commit beeea45d2e
2 changed files with 14 additions and 4 deletions

View File

@ -3431,6 +3431,8 @@ void VoIPController::UpdateQueuedPackets(){
}
void VoIPController::SendNopPacket(){
if(state!=STATE_ESTABLISHED)
return;
SendOrEnqueuePacket(PendingOutgoingPacket{
/*.seq=*/(firstSentPing=GenerateOutSeq()),
/*.type=*/PKT_NOP,

View File

@ -403,13 +403,11 @@ namespace tgvoip{
double ackTime;
};
struct PendingOutgoingPacket{
#if defined(_MSC_VER) && _MSC_VER <= 1800 // VS2013 doesn't support auto-generating move constructors
//TGVOIP_DISALLOW_COPY_AND_ASSIGN(PendingOutgoingPacket);
PendingOutgoingPacket(uint32_t seq, unsigned char type, size_t len, Buffer&& data, int64_t endpoint){
this->seq=seq;
this->type=type;
this->len=len;
this->data=data;
this->data=std::move(data);
this->endpoint=endpoint;
}
PendingOutgoingPacket(PendingOutgoingPacket&& other){
@ -419,7 +417,17 @@ namespace tgvoip{
data=std::move(other.data);
endpoint=other.endpoint;
}
#endif
PendingOutgoingPacket& operator=(PendingOutgoingPacket&& other){
if(this!=&other){
seq=other.seq;
type=other.type;
len=other.len;
data=std::move(other.data);
endpoint=other.endpoint;
}
return *this;
}
TGVOIP_DISALLOW_COPY_AND_ASSIGN(PendingOutgoingPacket);
uint32_t seq;
unsigned char type;
size_t len;