yiguolei commented on code in PR #39524:
URL: https://github.com/apache/doris/pull/39524#discussion_r1720938155


##########
be/src/util/byte_buffer.h:
##########
@@ -56,14 +64,15 @@ struct ByteBuffer {
     size_t remaining() const { return limit - pos; }
     bool has_remaining() const { return limit > pos; }
 
-    char* const ptr;
+    char* ptr;
     size_t pos;
     size_t limit;
     size_t capacity;
 
 private:
-    ByteBuffer(size_t capacity_)
-            : ptr(new char[capacity_]), pos(0), limit(capacity_), 
capacity(capacity_) {}
+    ByteBuffer(size_t capacity_) : pos(0), limit(capacity_), 
capacity(capacity_) {
+        ptr = reinterpret_cast<char*>(Allocator<false>::alloc(capacity_));

Review Comment:
   一般你这么写风险很高,比如在74 行构造函数里发生了内存申请,假如capactity 很大,此时申请失败了,如何处理?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to