Skip to content

Commit 7b17bac

Browse files
committed
Revert "Use make_unique_for_overwrite instead of malloc/free"
This reverts commit c7477e1.
1 parent ee580d4 commit 7b17bac

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

proxy/include/proxy/fileop.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ namespace fileop {
137137
}
138138

139139
const auto buf_size = 1024 * 1024 * 4;
140-
auto bufs = std::make_unique_for_overwrite<char[]>(buf_size);
140+
std::unique_ptr<char, decltype(&std::free)> bufs((char*)std::malloc(buf_size), &std::free);
141141

142142
while (file.read(bufs.get(),buf_size) || file.gcount() > 0)
143143
{

proxy/include/proxy/logging.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ namespace xlogging_compress__ {
269269
using gzFileType = typename std::remove_pointer<gzFile>::type;
270270
std::unique_ptr<gzFileType, closegz_deleter> gz_closer(out);
271271

272-
auto bufs = std::make_unique_for_overwrite<char[]>(LOGGING_GZ_BUFLEN);
272+
std::unique_ptr<char, decltype(&std::free)> bufs((char*)std::malloc(LOGGING_GZ_BUFLEN), &std::free);
273273
char* buf = bufs.get();
274274
int len;
275275

proxy/include/proxy/proxy_server.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,8 +3091,8 @@ R"x*x*x(<html>
30913091

30923092
constexpr auto buf_size = 512 * 1024;
30933093

3094-
auto buf0 = std::make_unique_for_overwrite<char[]>(buf_size);
3095-
auto buf1 = std::make_unique_for_overwrite<char[]>(buf_size);
3094+
std::unique_ptr<char, decltype(&std::free)> buf0((char*)std::malloc(buf_size), &std::free);
3095+
std::unique_ptr<char, decltype(&std::free)> buf1((char*)std::malloc(buf_size), &std::free);
30963096

30973097
// 分别使用主从缓冲指针用于并发读写.
30983098
auto primary_buf = buf0.get();
@@ -4284,7 +4284,7 @@ R"x*x*x(<html>
42844284
if (m_option.tcp_rate_limit_ > 0 && m_option.tcp_rate_limit_ < buf_size)
42854285
buf_size = m_option.tcp_rate_limit_;
42864286

4287-
auto bufs = std::make_unique_for_overwrite<char[]>(buf_size);
4287+
std::unique_ptr<char, decltype(&std::free)> bufs((char*)std::malloc(buf_size), &std::free);
42884288
char* buf = bufs.get();
42894289

42904290
std::streamsize total = 0;

0 commit comments

Comments
 (0)