MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / CopyFromRaw

Method CopyFromRaw

rapidjson/pointer.h:759–783  ·  view source on GitHub ↗

Clone the content from rhs to this. ! \param rhs Source pointer. \param extraToken Extra tokens to be allocated. \param extraNameBufferSize Extra name buffer size (in number of Ch) to be allocated. \return Start of non-occupied name buffer, for storing extra names. */

Source from the content-addressed store, hash-verified

757 \return Start of non-occupied name buffer, for storing extra names.
758 */
759 Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) {
760 if (!allocator_) // allocator is independently owned.
761 ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
762
763 size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens
764 for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t)
765 nameBufferSize += t->length;
766
767 tokenCount_ = rhs.tokenCount_ + extraToken;
768 tokens_ = static_cast<Token *>(allocator_->Malloc(tokenCount_ * sizeof(Token) + (nameBufferSize + extraNameBufferSize) * sizeof(Ch)));
769 nameBuffer_ = reinterpret_cast<Ch *>(tokens_ + tokenCount_);
770 if (rhs.tokenCount_ > 0) {
771 std::memcpy(tokens_, rhs.tokens_, rhs.tokenCount_ * sizeof(Token));
772 }
773 if (nameBufferSize > 0) {
774 std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));
775 }
776
777 // Adjust pointers to name buffer
778 std::ptrdiff_t diff = nameBuffer_ - rhs.nameBuffer_;
779 for (Token *t = tokens_; t != tokens_ + rhs.tokenCount_; ++t)
780 t->name += diff;
781
782 return nameBuffer_ + nameBufferSize;
783 }
784
785 //! Check whether a character should be percent-encoded.
786 /*!

Callers 1

AppendMethod · 0.80

Calls 1

MallocMethod · 0.45

Tested by

no test coverage detected