[rtmpdump] r42 - rtmp.cpp rtmpdump.cpp
hyc
subversion at mplayerhq.hu
Tue Nov 10 12:19:47 CET 2009
Author: hyc
Date: Tue Nov 10 12:19:47 2009
New Revision: 42
Log:
More memory cleanup
Modified:
rtmp.cpp
rtmpdump.cpp
Modified: rtmp.cpp
==============================================================================
--- rtmp.cpp Tue Nov 10 12:00:55 2009 (r41)
+++ rtmp.cpp Tue Nov 10 12:19:47 2009 (r42)
@@ -1472,10 +1472,14 @@ bool CRTMP::ReadPacket(RTMPPacket &packe
if (nSize == 11)
packet.m_nInfoField2 = ReadInt32LE(header+7);
- if (packet.m_nBodySize > 0 && packet.m_body == NULL && !packet.AllocPacket(packet.m_nBodySize))
+ bool didAlloc = false;
+ if (packet.m_nBodySize > 0 && packet.m_body == NULL)
{
- Log(LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
- return false;
+ if (!packet.AllocPacket(packet.m_nBodySize)) {
+ Log(LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
+ return false;
+ }
+ didAlloc = true;
}
int nToRead = packet.m_nBodySize - packet.m_nBytesRead;
@@ -1486,8 +1490,10 @@ bool CRTMP::ReadPacket(RTMPPacket &packe
if (ReadN(packet.m_body + packet.m_nBytesRead, nChunk) != nChunk)
{
Log(LOGERROR, "%s, failed to read RTMP packet body. len: %lu", __FUNCTION__, packet.m_nBodySize);
- packet.m_body = NULL; // we dont want it deleted since its pointed to from the stored packets (m_vecChannelsIn)
- packet.m_buffer = NULL;
+ if (!didAlloc) {
+ packet.m_body = NULL; // we dont want it deleted since its pointed to from the stored packets (m_vecChannelsIn)
+ packet.m_buffer = NULL;
+ }
return false;
}
Modified: rtmpdump.cpp
==============================================================================
--- rtmpdump.cpp Tue Nov 10 12:00:55 2009 (r41)
+++ rtmpdump.cpp Tue Nov 10 12:19:47 2009 (r42)
@@ -1237,12 +1237,8 @@ int main(int argc, char **argv)
strcpy(tcUrl, str);
}
- int bufferSize = 1024*1024;
- char *buffer = (char *)malloc(bufferSize);
int first = 1;
- memset(buffer, 0, bufferSize);
-
// User defined seek offset
if (dStartOffset > 0) {
// Live stream
More information about the rtmpdump
mailing list