void IOBuf::cloneOneInto(IOBuf& other) const { SharedInfo* info = sharedInfo(); if (info) { setFlags(kFlagMaybeShared); } other = IOBuf(InternalConstructor(), flagsAndSharedInfo_, buf_, capacity_, data_, length_); if (info) { info->refcount.fetch_add(1, std::memory_order_acq_rel); } }
IOBuf IOBuf::cloneOneAsValue() const { if (SharedInfo* info = sharedInfo()) { setFlags(kFlagMaybeShared); info->refcount.fetch_add(1, std::memory_order_acq_rel); } return IOBuf( InternalConstructor(), flagsAndSharedInfo_, buf_, capacity_, data_, length_); }
unique_ptr<IOBuf> IOBuf::createCombined(uint64_t capacity) { // To save a memory allocation, allocate space for the IOBuf object, the // SharedInfo struct, and the data itself all with a single call to malloc(). size_t requiredStorage = offsetof(HeapFullStorage, align) + capacity; size_t mallocSize = goodMallocSize(requiredStorage); auto* storage = static_cast<HeapFullStorage*>(malloc(mallocSize)); new (&storage->hs.prefix) HeapPrefix(kIOBufInUse | kDataInUse); new (&storage->shared) SharedInfo(freeInternalBuf, storage); uint8_t* bufAddr = reinterpret_cast<uint8_t*>(&storage->align); uint8_t* storageEnd = reinterpret_cast<uint8_t*>(storage) + mallocSize; size_t actualCapacity = size_t(storageEnd - bufAddr); unique_ptr<IOBuf> ret(new (&storage->hs.buf) IOBuf( InternalConstructor(), packFlagsAndSharedInfo(0, &storage->shared), bufAddr, actualCapacity, bufAddr, 0)); return ret; }
//************************************************************************* // Method: DisplayableDataNode // Description: Constructor for the DisplayableDataNode class // // Parameters: // Name - name of the node // Type - type of the node // pID - process ID for the node // tID - thread ID for the node // // Return Value: None //************************************************************************* DisplayableDataNode::DisplayableDataNode(String *Name, NodeType Type, int pID, int tID) { InternalConstructor(Name, Type, pID, tID); }
//************************************************************************* // Method: DisplayableDataNode // Description: Constructor for the DisplayableDataNode class // // Parameters: // dataNode - node to copy // // Return Value: None //************************************************************************* DisplayableDataNode::DisplayableDataNode(DisplayableDataNode *dataNode) { InternalConstructor(dataNode); }
MemoryStream::MemoryStream(const SharedPtr<ByteArray>& buffer, int32 index, int32 count) :_streamClosed(false) ,_dirty_bytes(0) { InternalConstructor(buffer, index, count, true, false); }