From 6e8c4a1387398dfffdf025132c7f58368a34d83b Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 7 May 2023 07:35:38 +0000 Subject: [PATCH] 1 --- server/wsproxy/upstream.cc | 5 +---- server/wsproxy/upstream.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/server/wsproxy/upstream.cc b/server/wsproxy/upstream.cc index 03d3f23..b76df15 100644 --- a/server/wsproxy/upstream.cc +++ b/server/wsproxy/upstream.cc @@ -25,7 +25,6 @@ void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_po recv_bufflen_ = 0; last_pong_tick = a8::XGetTickCount(); - recv_buff_ = (char*) malloc(PACK_MAX * 2); tcp_client_ = std::make_shared(); tcp_client_->remote_address = remote_ip; tcp_client_->remote_port = remote_port; @@ -65,8 +64,6 @@ void UpStream::UnInit() abort(); } recv_bufflen_ = 0; - free(recv_buff_); - recv_buff_ = nullptr; } void UpStream::Open() @@ -240,7 +237,7 @@ void UpStream::on_socketread(a8::TcpClient* sender, char* buf, unsigned int len) f8::UdpLog::Instance()->Debug("recvied bad package", {}); } if (offset > 0 && offset < recv_bufflen_) { - memmove(recv_buff_, recv_buff_ + offset, recv_bufflen_ - offset); + memmove(recv_buff_.data(), recv_buff_.data() + offset, recv_bufflen_ - offset); } recv_bufflen_ -= offset; #if 1 diff --git a/server/wsproxy/upstream.h b/server/wsproxy/upstream.h index e0b37c3..b371546 100644 --- a/server/wsproxy/upstream.h +++ b/server/wsproxy/upstream.h @@ -64,7 +64,7 @@ class UpStream f8::MsgHdr* hdr); private: - char *recv_buff_ = nullptr; + std::array recv_buff_; unsigned int recv_bufflen_ = 0; std::shared_ptr tcp_client_; f8::TimerWp timer_wp_;