winlin

for memory leak detect, move the payload create to message.

... ... @@ -166,6 +166,18 @@ SrsCommonMessage::~SrsCommonMessage()
srs_freep(payload);
}
void SrsCommonMessage::create_payload(int size)
{
srs_freep(payload);
payload = new char[size];
srs_verbose("create payload for RTMP message. size=%d", size);
#ifdef SRS_MEM_WATCH
srs_memory_watch(payload, "RTMP.msg.payload", size);
#endif
}
SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload()
{
payload = NULL;
... ...
... ... @@ -283,8 +283,12 @@ public:
char* payload;
public:
SrsCommonMessage();
public:
virtual ~SrsCommonMessage();
public:
/**
* alloc the payload to specified size of bytes.
*/
virtual void create_payload(int size);
};
/**
... ...
... ... @@ -30,7 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_utility.hpp>
#include <srs_protocol_buffer.hpp>
#include <srs_rtmp_utility.hpp>
#include <srs_core_mem_watch.hpp>
// for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213
#ifndef _WIN32
... ... @@ -1411,11 +1410,7 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, SrsCommonMessage**
// create msg payload if not initialized
if (!chunk->msg->payload) {
chunk->msg->payload = new char[chunk->header.payload_length];
srs_verbose("create payload for RTMP message. size=%d", chunk->header.payload_length);
#ifdef SRS_MEM_WATCH
srs_memory_watch(chunk->msg->payload, "msg.payload", chunk->header.payload_length);
#endif
chunk->msg->create_payload(chunk->header.payload_length);
}
// read payload to buffer
... ...