MCPcopy Create free account
hub / github.com/Illumina/hap.py / allocate

Method allocate

external/jsoncpp/jsoncpp.cpp:1099–1121  ·  view source on GitHub ↗

allocate space for an array of objectPerAllocation object. @warning it is the responsability of the caller to call objects constructors.

Source from the content-addressed store, hash-verified

1097 /// @warning it is the responsability of the caller to call objects
1098 /// constructors.
1099 AllocatedType *allocate() {
1100 if (freeHead_) // returns node from free list.
1101 {
1102 AllocatedType *object = freeHead_;
1103 freeHead_ = *(AllocatedType **)object;
1104 return object;
1105 }
1106 if (currentBatch_->used_ == currentBatch_->end_) {
1107 currentBatch_ = currentBatch_->next_;
1108 while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)
1109 currentBatch_ = currentBatch_->next_;
1110
1111 if (!currentBatch_) // no free batch found, allocate a new one
1112 {
1113 currentBatch_ = allocateBatch(objectsPerPage_);
1114 currentBatch_->next_ = batches_; // insert at the head of the list
1115 batches_ = currentBatch_;
1116 }
1117 }
1118 AllocatedType *allocated = currentBatch_->used_;
1119 currentBatch_->used_ += objectPerAllocation;
1120 return allocated;
1121 }
1122
1123 /// Release the object.
1124 /// @warning it is the responsability of the caller to actually destruct the

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected