1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/src/protocol/srs_protocol_rtmp_msg_array.cpp

49 lines
887 B
C++
Raw Normal View History

//
2024-01-01 02:51:24 +00:00
// Copyright (c) 2013-2024 The SRS Authors
//
2023-10-23 06:33:19 +00:00
// SPDX-License-Identifier: MIT
//
#include <srs_protocol_rtmp_msg_array.hpp>
#include <srs_protocol_rtmp_stack.hpp>
SrsMessageArray::SrsMessageArray(int max_msgs)
{
srs_assert(max_msgs > 0);
msgs = new SrsSharedPtrMessage*[max_msgs];
max = max_msgs;
zero(max_msgs);
}
SrsMessageArray::~SrsMessageArray()
{
// we just free the msgs itself,
// both delete and delete[] is ok,
2019-04-22 00:12:17 +00:00
// for all msgs is already freed by send_and_free_messages.
srs_freepa(msgs);
}
void SrsMessageArray::free(int count)
{
// initialize
for (int i = 0; i < count; i++) {
SrsSharedPtrMessage* msg = msgs[i];
srs_freep(msg);
msgs[i] = NULL;
}
}
void SrsMessageArray::zero(int count)
{
// initialize
for (int i = 0; i < count; i++) {
msgs[i] = NULL;
}
}
2014-08-02 14:18:39 +00:00