1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine the ptr array free, 0.9.96

This commit is contained in:
winlin 2014-05-14 09:58:42 +08:00
parent dc66c525fd
commit 3ebda13802
5 changed files with 58 additions and 49 deletions

View file

@ -352,6 +352,7 @@ int SrsForwarder::forward()
srs_verbose("no packets to forward.");
continue;
}
SrsAutoFreeArray(SrsSharedPtrMessage, msgs, count);
// all msgs to forward.
// @remark, becareful, all msgs must be free explicitly,
@ -362,23 +363,11 @@ int SrsForwarder::forward()
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);
continue;
return ret;
}
}
// free the array itself.
srs_freep(msgs);
if (ret != ERROR_SUCCESS) {
return ret;
}
}
return ret;