MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / DetachedBuffer

Class DetachedBuffer

native/thirdpart/flatbuffers/flatbuffers.h:747–866  ·  view source on GitHub ↗

DetachedBuffer is a finished flatbuffer memory region, detached from its builder. The original memory region and allocator are also stored so that the DetachedBuffer can manage the memory lifetime.

Source from the content-addressed store, hash-verified

745// builder. The original memory region and allocator are also stored so that
746// the DetachedBuffer can manage the memory lifetime.
747class DetachedBuffer {
748 public:
749 DetachedBuffer()
750 : allocator_(nullptr),
751 own_allocator_(false),
752 buf_(nullptr),
753 reserved_(0),
754 cur_(nullptr),
755 size_(0) {}
756
757 DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf,
758 size_t reserved, uint8_t *cur, size_t sz)
759 : allocator_(allocator),
760 own_allocator_(own_allocator),
761 buf_(buf),
762 reserved_(reserved),
763 cur_(cur),
764 size_(sz) {}
765
766 // clang-format off
767 #if !defined(FLATBUFFERS_CPP98_STL)
768 // clang-format on
769 DetachedBuffer(DetachedBuffer &&other)
770 : allocator_(other.allocator_),
771 own_allocator_(other.own_allocator_),
772 buf_(other.buf_),
773 reserved_(other.reserved_),
774 cur_(other.cur_),
775 size_(other.size_) {
776 other.reset();
777 }
778 // clang-format off
779 #endif // !defined(FLATBUFFERS_CPP98_STL)
780 // clang-format on
781
782 // clang-format off
783 #if !defined(FLATBUFFERS_CPP98_STL)
784 // clang-format on
785 DetachedBuffer &operator=(DetachedBuffer &&other) {
786 if (this == &other) return *this;
787
788 destroy();
789
790 allocator_ = other.allocator_;
791 own_allocator_ = other.own_allocator_;
792 buf_ = other.buf_;
793 reserved_ = other.reserved_;
794 cur_ = other.cur_;
795 size_ = other.size_;
796
797 other.reset();
798
799 return *this;
800 }
801 // clang-format off
802 #endif // !defined(FLATBUFFERS_CPP98_STL)
803 // clang-format on
804

Callers 1

TextToFlatBufferMethod · 0.85

Calls 2

destroyFunction · 0.85
resetMethod · 0.45

Tested by

no test coverage detected