[SCM] kodi-pvr-vdr-vnsi/master: responsepacket: do not transfer ownership in getUserData()
tiber-guest at users.alioth.debian.org
tiber-guest at users.alioth.debian.org
Sun Feb 28 15:46:49 UTC 2016
The following commit has been merged in the master branch:
commit 0917b9d2ed31951090f85e1dcb0b55edc6c22d5e
Author: Max Kellermann <max at duempel.org>
Date: Thu Nov 5 22:28:03 2015 +0100
responsepacket: do not transfer ownership in getUserData()
This is a fragile thing to do, and cumbersome for callers to
implement. Just one caller is interested in adopting allocation
ownership, and no caller is exception-safe. That one caller gets a
new (simpler) method called stealUserData().
diff --git a/src/VNSIAdmin.cpp b/src/VNSIAdmin.cpp
index cfec975..5b8dbaf 100644
--- a/src/VNSIAdmin.cpp
+++ b/src/VNSIAdmin.cpp
@@ -1320,7 +1320,6 @@ bool cVNSIAdmin::OnResponsePacket(cResponsePacket* resp)
if (m_osdRender)
m_osdRender->AddTexture(wnd, color, x0, y0, x1, y1, data[0]);
m_osdMutex.Unlock();
- free(data);
}
else if (resp->getOpCodeID() == VNSI_OSD_SETPALETTE)
{
@@ -1330,7 +1329,6 @@ bool cVNSIAdmin::OnResponsePacket(cResponsePacket* resp)
if (m_osdRender)
m_osdRender->SetPalette(wnd, x0, (uint32_t*)data);
m_osdMutex.Unlock();
- free(data);
}
else if (resp->getOpCodeID() == VNSI_OSD_SETBLOCK)
{
@@ -1343,7 +1341,6 @@ bool cVNSIAdmin::OnResponsePacket(cResponsePacket* resp)
m_bIsOsdDirty = true;
}
m_osdMutex.Unlock();
- free(data);
}
else if (resp->getOpCodeID() == VNSI_OSD_CLEAR)
{
diff --git a/src/VNSIDemux.cpp b/src/VNSIDemux.cpp
index a99f8af..24bc6c7 100644
--- a/src/VNSIDemux.cpp
+++ b/src/VNSIDemux.cpp
@@ -114,7 +114,7 @@ DemuxPacket* cVNSIDemux::Read()
// stream found ?
if(iStreamId != -1 && resp->getMuxSerial() == m_MuxPacketSerial)
{
- DemuxPacket* p = (DemuxPacket*)resp->getUserData();
+ DemuxPacket* p = (DemuxPacket*)resp->stealUserData();
p->iSize = resp->getUserDataLength();
p->duration = (double)resp->getDuration() * DVD_TIME_BASE / 1000000;
p->dts = (double)resp->getDTS() * DVD_TIME_BASE / 1000000;
diff --git a/src/VNSIRecording.cpp b/src/VNSIRecording.cpp
index 6a18940..389723f 100644
--- a/src/VNSIRecording.cpp
+++ b/src/VNSIRecording.cpp
@@ -117,14 +117,12 @@ int cVNSIRecording::Read(unsigned char* buf, uint32_t buf_size)
if (length > buf_size)
{
XBMC->Log(LOG_ERROR, "%s: PANIC - Received more bytes as requested", __FUNCTION__);
- free(data);
delete vresp;
return 0;
}
memcpy(buf, data, length);
m_currentPlayingRecordPosition += length;
- free(data);
delete vresp;
return length;
}
diff --git a/src/responsepacket.cpp b/src/responsepacket.cpp
index 48293fe..6eb3a72 100644
--- a/src/responsepacket.cpp
+++ b/src/responsepacket.cpp
@@ -32,7 +32,6 @@ cResponsePacket::cResponsePacket()
userDataLength = 0;
packetPos = 0;
userData = NULL;
- ownBlock = true;
channelID = 0;
requestID = 0;
streamID = 0;
@@ -40,8 +39,6 @@ cResponsePacket::cResponsePacket()
cResponsePacket::~cResponsePacket()
{
- if (!ownBlock) return; // don't free if it's a getblock
-
if (userData)
{
if (channelID == VNSI_CHANNEL_STREAM && opcodeID == VNSI_STREAM_MUXPKT)
@@ -223,6 +220,12 @@ int64_t cResponsePacket::extract_S64()
uint8_t* cResponsePacket::getUserData()
{
- ownBlock = false;
return userData;
}
+
+uint8_t* cResponsePacket::stealUserData()
+{
+ uint8_t *result = userData;
+ userData = NULL;
+ return result;
+}
diff --git a/src/responsepacket.h b/src/responsepacket.h
index e741f27..08b9889 100644
--- a/src/responsepacket.h
+++ b/src/responsepacket.h
@@ -67,6 +67,8 @@ class cResponsePacket
double extract_Double();
// If you call this, the memory becomes yours. Free with free()
+ uint8_t* stealUserData();
+
uint8_t* getUserData();
uint8_t* getHeader() { return header; };
@@ -93,6 +95,4 @@ class cResponsePacket
int32_t osdWnd;
int32_t osdColor;
int32_t osdX0,osdY0,osdX1,osdY1;
-
- bool ownBlock;
};
--
kodi-pvr-vdr-vnsi packaging
More information about the pkg-multimedia-commits
mailing list