| 485 | T* data; |
| 486 | |
| 487 | void ensureCapacity(size_type newcapacity, bool preserve = true) |
| 488 | { |
| 489 | if (newcapacity > capacity) |
| 490 | { |
| 491 | if (capacity <= FB_MAX_SIZEOF / 2) |
| 492 | { |
| 493 | if (newcapacity < capacity * 2) |
| 494 | newcapacity = capacity * 2; |
| 495 | } |
| 496 | else |
| 497 | { |
| 498 | newcapacity = FB_MAX_SIZEOF; |
| 499 | } |
| 500 | |
| 501 | // Ensure we can carry byte copy operations. |
| 502 | // What to do here, throw in release build? |
| 503 | fb_assert(newcapacity < FB_MAX_SIZEOF / sizeof(T)); |
| 504 | |
| 505 | T* newdata = static_cast<T*> |
| 506 | (this->getPool().allocate(sizeof(T) * newcapacity ALLOC_ARGS)); |
| 507 | if (preserve) |
| 508 | memcpy(newdata, data, sizeof(T) * count); |
| 509 | freeData(); |
| 510 | data = newdata; |
| 511 | capacity = newcapacity; |
| 512 | } |
| 513 | } |
| 514 | }; |
| 515 | |
| 516 | const static int FB_ARRAY_SORT_MANUAL = 0; |