------------------------------------------------------------------------------ Allocate memory for this array. Delete old storage only if necessary.
| 172 | //------------------------------------------------------------------------------ |
| 173 | // Allocate memory for this array. Delete old storage only if necessary. |
| 174 | vtkTypeBool vtkBitArray::Allocate(vtkIdType sz, vtkIdType vtkNotUsed(ext)) |
| 175 | { |
| 176 | if (sz > this->Size) |
| 177 | { |
| 178 | if (this->DeleteFunction) |
| 179 | { |
| 180 | this->DeleteFunction(this->Array); |
| 181 | } |
| 182 | this->Size = (sz > 0 ? sz : 1); |
| 183 | this->Array = new ValueType[(this->Size + 7) / 8]; |
| 184 | if (this->Array == nullptr) |
| 185 | { |
| 186 | vtkErrorMacro(<< "Cannot allocate memory\n"); |
| 187 | return 0; |
| 188 | } |
| 189 | this->DeleteFunction = ::operator delete[]; |
| 190 | } |
| 191 | |
| 192 | this->MaxId = -1; |
| 193 | this->DataChanged(); |
| 194 | |
| 195 | return 1; |
| 196 | } |
| 197 | |
| 198 | //------------------------------------------------------------------------------ |
| 199 | // Release storage and reset array to initial state. |
no test coverage detected