From befde6acf724ebcbeb70b2e62dc3fc311bbeebc7 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 13 May 2014 14:24:39 +0800 Subject: [PATCH] fix mem leak for delete[] SharedPtrMessage array, explicit free elems. remove srs_freepa. 0.9.95 --- trunk/src/app/srs_app_codec.cpp | 18 +- trunk/src/app/srs_app_config.cpp | 14 +- trunk/src/app/srs_app_conn.cpp | 2 +- trunk/src/app/srs_app_edge.cpp | 19 +- trunk/src/app/srs_app_ffmpeg.cpp | 2 +- trunk/src/app/srs_app_forward.cpp | 17 +- trunk/src/app/srs_app_http.cpp | 2 +- trunk/src/app/srs_app_log.cpp | 2 +- trunk/src/app/srs_app_rtmp_conn.cpp | 17 +- trunk/src/app/srs_app_source.cpp | 2 +- trunk/src/core/srs_core.hpp | 258 ++++++++++----------- trunk/src/libs/srs_librtmp.cpp | 8 +- trunk/src/rtmp/srs_protocol_handshake.cpp | 8 +- trunk/src/rtmp/srs_protocol_rtmp.cpp | 6 +- trunk/src/rtmp/srs_protocol_rtmp_stack.cpp | 8 +- 15 files changed, 209 insertions(+), 174 deletions(-) mode change 100755 => 100644 trunk/src/core/srs_core.hpp diff --git a/trunk/src/app/srs_app_codec.cpp b/trunk/src/app/srs_app_codec.cpp index 2a68625ae..65da8d7b4 100644 --- a/trunk/src/app/srs_app_codec.cpp +++ b/trunk/src/app/srs_app_codec.cpp @@ -50,7 +50,7 @@ void SrsCodecBuffer::append(void* data, int len) void SrsCodecBuffer::free() { size = 0; - srs_freepa(bytes); + srs_freep(bytes); } SrsCodecSample::SrsCodecSample() @@ -125,12 +125,12 @@ SrsCodec::SrsCodec() SrsCodec::~SrsCodec() { - srs_freepa(avc_extra_data); - srs_freepa(aac_extra_data); + srs_freep(avc_extra_data); + srs_freep(aac_extra_data); srs_freep(stream); - srs_freepa(sequenceParameterSetNALUnit); - srs_freepa(pictureParameterSetNALUnit); + srs_freep(sequenceParameterSetNALUnit); + srs_freep(pictureParameterSetNALUnit); } int SrsCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* sample) @@ -207,7 +207,7 @@ int SrsCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* sample) // 1.6.2.1 AudioSpecificConfig, in aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 33. aac_extra_size = stream->left(); if (aac_extra_size > 0) { - srs_freepa(aac_extra_data); + srs_freep(aac_extra_data); aac_extra_data = new char[aac_extra_size]; memcpy(aac_extra_data, stream->current(), aac_extra_size); } @@ -321,7 +321,7 @@ int SrsCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* sample) // 5.2.4.1.1 Syntax, H.264-AVC-ISO_IEC_14496-15.pdf, page 16 avc_extra_size = stream->left(); if (avc_extra_size > 0) { - srs_freepa(avc_extra_data); + srs_freep(avc_extra_data); avc_extra_data = new char[avc_extra_size]; memcpy(avc_extra_data, stream->current(), avc_extra_size); } @@ -366,7 +366,7 @@ int SrsCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* sample) return ret; } if (sequenceParameterSetLength > 0) { - srs_freepa(sequenceParameterSetNALUnit); + srs_freep(sequenceParameterSetNALUnit); sequenceParameterSetNALUnit = new char[sequenceParameterSetLength]; memcpy(sequenceParameterSetNALUnit, stream->current(), sequenceParameterSetLength); stream->skip(sequenceParameterSetLength); @@ -396,7 +396,7 @@ int SrsCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* sample) return ret; } if (pictureParameterSetLength > 0) { - srs_freepa(pictureParameterSetNALUnit); + srs_freep(pictureParameterSetNALUnit); pictureParameterSetNALUnit = new char[pictureParameterSetLength]; memcpy(pictureParameterSetNALUnit, stream->current(), pictureParameterSetLength); stream->skip(pictureParameterSetLength); diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index e317113cf..3b570e320 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -93,7 +93,7 @@ SrsFileBuffer::SrsFileBuffer() SrsFileBuffer::~SrsFileBuffer() { - srs_freepa(start); + srs_freep(start); } int SrsFileBuffer::fullfill(const char* filename) @@ -117,7 +117,7 @@ int SrsFileBuffer::fullfill(const char* filename) goto finish; } - srs_freepa(start); + srs_freep(start); pos = last = start = new char[filesize]; end = start + filesize; @@ -407,15 +407,15 @@ int SrsConfDirective::read_token(SrsFileBuffer* buffer, vector& args) if (found) { int len = buffer->pos - pstart; - char* word = new char[len]; - memcpy(word, pstart, len); - word[len - 1] = 0; + char* aword = new char[len]; + memcpy(aword, pstart, len); + aword[len - 1] = 0; - string word_str = word; + string word_str = aword; if (!word_str.empty()) { args.push_back(word_str); } - srs_freepa(word); + srs_freep(aword); if (ch == ';') { return ERROR_SYSTEM_CONFIG_DIRECTIVE; diff --git a/trunk/src/app/srs_app_conn.cpp b/trunk/src/app/srs_app_conn.cpp index 8e520712d..539eeb89c 100644 --- a/trunk/src/app/srs_app_conn.cpp +++ b/trunk/src/app/srs_app_conn.cpp @@ -87,7 +87,7 @@ void SrsConnection::stop() { srs_close_stfd(stfd); srs_freep(pthread); - srs_freepa(ip); + srs_freep(ip); } int SrsConnection::get_peer_ip() diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 3c722eead..06c822500 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -474,20 +474,33 @@ int SrsEdgeForwarder::cycle() srs_verbose("no packets to forward."); continue; } - SrsAutoFree(SrsSharedPtrMessage*, msgs, true); - // all msgs to forward. + // all msgs to forward to origin. + // @remark, becareful, all msgs must be free explicitly, + // free by send_and_free_message or srs_freep. for (int i = 0; i < count; i++) { SrsSharedPtrMessage* msg = msgs[i]; srs_assert(msg); msgs[i] = NULL; + // never use free msgs array, for it will memory leak. + // if error, directly free msgs. + if (ret != ERROR_SUCCESS) { + srs_freep(msg); + continue; + } + if ((ret = client->send_and_free_message(msg)) != ERROR_SUCCESS) { srs_error("edge publish forwarder send message to server failed. ret=%d", ret); - return ret; + break; } } + // free the array itself. + srs_freep(msgs); + if (ret != ERROR_SUCCESS) { + return ret; + } } return ret; diff --git a/trunk/src/app/srs_app_ffmpeg.cpp b/trunk/src/app/srs_app_ffmpeg.cpp index ddbc2c107..50a7b883a 100644 --- a/trunk/src/app/srs_app_ffmpeg.cpp +++ b/trunk/src/app/srs_app_ffmpeg.cpp @@ -360,7 +360,7 @@ int SrsFFMPEG::start() } srs_trace("start transcoder, log: %s, params: %s", log_file.c_str(), pparam); - srs_freepa(pparam); + srs_freep(pparam); } // TODO: fork or vfork? diff --git a/trunk/src/app/srs_app_forward.cpp b/trunk/src/app/srs_app_forward.cpp index b70c3199b..45a35d0b8 100644 --- a/trunk/src/app/srs_app_forward.cpp +++ b/trunk/src/app/srs_app_forward.cpp @@ -352,20 +352,33 @@ int SrsForwarder::forward() srs_verbose("no packets to forward."); continue; } - SrsAutoFree(SrsSharedPtrMessage*, msgs, true); // all msgs to forward. + // @remark, becareful, all msgs must be free explicitly, + // free by send_and_free_message or srs_freep. for (int i = 0; i < count; i++) { SrsSharedPtrMessage* msg = msgs[i]; srs_assert(msg); msgs[i] = NULL; + // never use free msgs array, for it will memory leak. + // if error, directly free msgs. + if (ret != ERROR_SUCCESS) { + srs_freep(msg); + continue; + } + if ((ret = client->send_and_free_message(msg)) != ERROR_SUCCESS) { srs_error("forwarder send message to server failed. ret=%d", ret); - return ret; + break; } } + // free the array itself. + srs_freep(msgs); + if (ret != ERROR_SUCCESS) { + return ret; + } } return ret; diff --git a/trunk/src/app/srs_app_http.cpp b/trunk/src/app/srs_app_http.cpp index 2c79f9073..363cdbf61 100644 --- a/trunk/src/app/srs_app_http.cpp +++ b/trunk/src/app/srs_app_http.cpp @@ -523,7 +523,7 @@ SrsHttpMessage::~SrsHttpMessage() srs_freep(_body); srs_freep(_uri); srs_freep(_match); - srs_freepa(_http_ts_send_buffer); + srs_freep(_http_ts_send_buffer); } char* SrsHttpMessage::http_ts_send_buffer() diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp index f36363ba9..6df566178 100644 --- a/trunk/src/app/srs_app_log.cpp +++ b/trunk/src/app/srs_app_log.cpp @@ -72,7 +72,7 @@ SrsFastLog::SrsFastLog() SrsFastLog::~SrsFastLog() { - srs_freepa(log_data); + srs_freep(log_data); if (fd > 0) { ::close(fd); diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 47d1c63ce..6e0810eb1 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -513,9 +513,10 @@ int SrsRtmpConn::playing(SrsSource* source) srs_verbose("no packets in queue."); continue; } - SrsAutoFree(SrsSharedPtrMessage*, msgs, true); // sendout messages + // @remark, becareful, all msgs must be free explicitly, + // free by send_and_free_message or srs_freep. for (int i = 0; i < count; i++) { SrsSharedPtrMessage* msg = msgs[i]; @@ -525,6 +526,13 @@ int SrsRtmpConn::playing(SrsSource* source) srs_assert(msg); + // never use free msgs array, for it will memory leak. + // if error, directly free msgs. + if (ret != ERROR_SUCCESS) { + srs_freep(msg); + continue; + } + // foreach msg, collect the duration. // @remark: never use msg when sent it, for the protocol sdk will free it. if (starttime < 0 || starttime > msg->header.timestamp) { @@ -535,9 +543,14 @@ int SrsRtmpConn::playing(SrsSource* source) if ((ret = rtmp->send_and_free_message(msg)) != ERROR_SUCCESS) { srs_error("send message to client failed. ret=%d", ret); - return ret; + break; } } + // free the array itself. + srs_freep(msgs); + if (ret != ERROR_SUCCESS) { + return ret; + } // if duration specified, and exceed it, stop play live. // @see: https://github.com/winlinvip/simple-rtmp-server/issues/45 diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 57236b501..2bdc934c8 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -844,7 +844,7 @@ int SrsSource::on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata) char* payload = NULL; if ((ret = metadata->encode(size, payload)) != ERROR_SUCCESS) { srs_error("encode metadata error. ret=%d", ret); - srs_freepa(payload); + srs_freep(payload); return ret; } srs_verbose("encode metadata success."); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp old mode 100755 new mode 100644 index 7a2f95e08..5c4f369a8 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -1,131 +1,127 @@ -/* -The MIT License (MIT) - -Copyright (c) 2013-2014 winlin - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef SRS_CORE_HPP -#define SRS_CORE_HPP - -/* -#include -*/ - -// current release version -#define VERSION_MAJOR "0" -#define VERSION_MINOR "9" -#define VERSION_REVISION "94" -#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION -// server info. -#define RTMP_SIG_SRS_KEY "srs" -#define RTMP_SIG_SRS_ROLE "origin/edge server" -#define RTMP_SIG_SRS_NAME RTMP_SIG_SRS_KEY"(simple rtmp server)" -#define RTMP_SIG_SRS_URL_SHORT "github.com/winlinvip/simple-rtmp-server" -#define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT -#define RTMP_SIG_SRS_WEB "http://blog.csdn.net/win_lin" -#define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com" -#define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)" -#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2014 winlin" -#define RTMP_SIG_SRS_PRIMARY_AUTHROS "winlin,wenjie.zhao" -#define RTMP_SIG_SRS_CONTRIBUTORS_URL RTMP_SIG_SRS_URL"/blob/master/AUTHORS.txt" - -/** -* the core provides the common defined macros, utilities, -* user must include the srs_core.hpp before any header, or maybe -* build failed. -*/ - -// for 32bit os, 2G big file limit for unistd io, -// ie. read/write/lseek to use 64bits size for huge file. -#ifndef _FILE_OFFSET_BITS - #define _FILE_OFFSET_BITS 64 -#endif - -// for int64_t print using PRId64 format. -#ifndef __STDC_FORMAT_MACROS - #define __STDC_FORMAT_MACROS -#endif -#include - -#include -#define srs_assert(expression) assert(expression) - -#include -#include - -// generated by configure. -#include - -// free the p and set to NULL. -// p must be a T*. -#define srs_freep(p) \ - if (p) { \ - delete p; \ - p = NULL; \ - } \ - (void)0 -// free the p which represents a array -#define srs_freepa(p) \ - if (p) { \ - delete[] p; \ - p = NULL; \ - } \ - (void)0 - -// compare -#define srs_min(a, b) (((a) < (b))? (a) : (b)) -#define srs_max(a, b) (((a) < (b))? (b) : (a)) - -// signal defines. -#define SIGNAL_RELOAD SIGHUP - -#include -// replace old_str to new_str of str -extern std::string srs_string_replace(std::string str, std::string old_str, std::string new_str); -// trim char in trim_chars of str -extern std::string srs_string_trim_end(std::string str, std::string trim_chars); -// trim char in trim_chars of str -extern std::string srs_string_trim_start(std::string str, std::string trim_chars); -// remove char in remove_chars of str -extern std::string srs_string_remove(std::string str, std::string remove_chars); -// whether string end with -extern bool srs_string_ends_with(std::string str, std::string flag); - -// dns resolve utility, return the resolved ip address. -extern std::string srs_dns_resolve(std::string host); -// whether system is little endian -extern bool srs_is_little_endian(); - -/** -* disable copy constructor of class -*/ -#define disable_default_copy(className)\ - private:\ - /** \ - * disable the copy constructor and operator=, donot allow directly copy. \ - */ \ - className(const className&); \ - className& operator= (const className&) - -// const time for st to convert to us -#define SRS_TIME_MILLISECONDS 1000 -#define SRS_TIME_SECONDS 1000000 - -#endif +/* +The MIT License (MIT) + +Copyright (c) 2013-2014 winlin + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef SRS_CORE_HPP +#define SRS_CORE_HPP + +/* +#include +*/ + +// current release version +#define VERSION_MAJOR "0" +#define VERSION_MINOR "9" +#define VERSION_REVISION "95" +#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION +// server info. +#define RTMP_SIG_SRS_KEY "srs" +#define RTMP_SIG_SRS_ROLE "origin/edge server" +#define RTMP_SIG_SRS_NAME RTMP_SIG_SRS_KEY"(simple rtmp server)" +#define RTMP_SIG_SRS_URL_SHORT "github.com/winlinvip/simple-rtmp-server" +#define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT +#define RTMP_SIG_SRS_WEB "http://blog.csdn.net/win_lin" +#define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com" +#define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)" +#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2014 winlin" +#define RTMP_SIG_SRS_PRIMARY_AUTHROS "winlin,wenjie.zhao" +#define RTMP_SIG_SRS_CONTRIBUTORS_URL RTMP_SIG_SRS_URL"/blob/master/AUTHORS.txt" + +/** +* the core provides the common defined macros, utilities, +* user must include the srs_core.hpp before any header, or maybe +* build failed. +*/ + +// for 32bit os, 2G big file limit for unistd io, +// ie. read/write/lseek to use 64bits size for huge file. +#ifndef _FILE_OFFSET_BITS + #define _FILE_OFFSET_BITS 64 +#endif + +// for int64_t print using PRId64 format. +#ifndef __STDC_FORMAT_MACROS + #define __STDC_FORMAT_MACROS +#endif +#include + +#include +#define srs_assert(expression) assert(expression) + +#include +#include + +// generated by configure. +#include + +// free the p and set to NULL. +// p must be a T*. +#define srs_freep(p) \ + if (p) { \ + delete p; \ + p = NULL; \ + } \ + (void)0 +// sometimes, the freepa is useless, +// it's recomments to free each elem explicit. +// so we remove the srs_freepa utility. + +// compare +#define srs_min(a, b) (((a) < (b))? (a) : (b)) +#define srs_max(a, b) (((a) < (b))? (b) : (a)) + +// signal defines. +#define SIGNAL_RELOAD SIGHUP + +#include +// replace old_str to new_str of str +extern std::string srs_string_replace(std::string str, std::string old_str, std::string new_str); +// trim char in trim_chars of str +extern std::string srs_string_trim_end(std::string str, std::string trim_chars); +// trim char in trim_chars of str +extern std::string srs_string_trim_start(std::string str, std::string trim_chars); +// remove char in remove_chars of str +extern std::string srs_string_remove(std::string str, std::string remove_chars); +// whether string end with +extern bool srs_string_ends_with(std::string str, std::string flag); + +// dns resolve utility, return the resolved ip address. +extern std::string srs_dns_resolve(std::string host); +// whether system is little endian +extern bool srs_is_little_endian(); + +/** +* disable copy constructor of class +*/ +#define disable_default_copy(className)\ + private:\ + /** \ + * disable the copy constructor and operator=, donot allow directly copy. \ + */ \ + className(const className&); \ + className& operator= (const className&) + +// const time for st to convert to us +#define SRS_TIME_MILLISECONDS 1000 +#define SRS_TIME_SECONDS 1000000 + +#endif diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index eb9d6127c..597fdf3a0 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -340,7 +340,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data, msg = new SrsSharedPtrMessage(); if ((ret = msg->initialize(&header, data, size)) != ERROR_SUCCESS) { - srs_freepa(data); + srs_freep(data); return ret; } } else if (type == SRS_RTMP_TYPE_VIDEO) { @@ -349,7 +349,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data, msg = new SrsSharedPtrMessage(); if ((ret = msg->initialize(&header, data, size)) != ERROR_SUCCESS) { - srs_freepa(data); + srs_freep(data); return ret; } } else if (type == SRS_RTMP_TYPE_SCRIPT) { @@ -358,7 +358,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data, msg = new SrsSharedPtrMessage(); if ((ret = msg->initialize(&header, data, size)) != ERROR_SUCCESS) { - srs_freepa(data); + srs_freep(data); return ret; } } @@ -370,7 +370,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data, } } else { // directly free data if not sent out. - srs_freepa(data); + srs_freep(data); } return ret; diff --git a/trunk/src/rtmp/srs_protocol_handshake.cpp b/trunk/src/rtmp/srs_protocol_handshake.cpp index 9c1801d49..b94d039e8 100644 --- a/trunk/src/rtmp/srs_protocol_handshake.cpp +++ b/trunk/src/rtmp/srs_protocol_handshake.cpp @@ -336,10 +336,10 @@ namespace srs void srs_key_block_free(key_block* key) { if (key->random0) { - srs_freepa(key->random0); + srs_freep(key->random0); } if (key->random1) { - srs_freepa(key->random1); + srs_freep(key->random1); } } @@ -427,10 +427,10 @@ namespace srs void srs_digest_block_free(digest_block* digest) { if (digest->random0) { - srs_freepa(digest->random0); + srs_freep(digest->random0); } if (digest->random1) { - srs_freepa(digest->random1); + srs_freep(digest->random1); } } diff --git a/trunk/src/rtmp/srs_protocol_rtmp.cpp b/trunk/src/rtmp/srs_protocol_rtmp.cpp index 0b82e759a..c4c8a3a38 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp.cpp @@ -192,9 +192,9 @@ SrsHandshakeBytes::SrsHandshakeBytes() SrsHandshakeBytes::~SrsHandshakeBytes() { - srs_freepa(c0c1); - srs_freepa(s0s1s2); - srs_freepa(c2); + srs_freep(c0c1); + srs_freep(s0s1s2); + srs_freep(c2); } int SrsHandshakeBytes::read_c0c1(ISrsProtocolReaderWriter* io) diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp index 0c81f3273..a8b2581f7 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp @@ -1538,7 +1538,7 @@ SrsCommonMessage::SrsCommonMessage() SrsCommonMessage::~SrsCommonMessage() { - srs_freepa(payload); + srs_freep(payload); } SrsSharedPtrMessage::__SrsSharedPtr::__SrsSharedPtr() @@ -1550,7 +1550,7 @@ SrsSharedPtrMessage::__SrsSharedPtr::__SrsSharedPtr() SrsSharedPtrMessage::__SrsSharedPtr::~__SrsSharedPtr() { - srs_freepa(payload); + srs_freep(payload); } SrsSharedPtrMessage::SrsSharedPtrMessage() @@ -1678,14 +1678,14 @@ int SrsPacket::encode(int& psize, char*& ppayload) if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) { srs_error("initialize the stream failed. ret=%d", ret); - srs_freepa(payload); + srs_freep(payload); return ret; } } if ((ret = encode_packet(&stream)) != ERROR_SUCCESS) { srs_error("encode the packet failed. ret=%d", ret); - srs_freepa(payload); + srs_freep(payload); return ret; }