| 631 } // LCOV_EXCL_STOP |
631 } // LCOV_EXCL_STOP |
| 632 new_source_allocator->cl = source->allocator->cl; |
632 new_source_allocator->cl = source->allocator->cl; |
| 633 new_source_allocator->data = source; |
633 new_source_allocator->data = source; |
| 634 |
634 |
| 635 // transfer all the data |
635 // transfer all the data |
| 636 memcpy(&dest->data[dest->size], source->data, sizeof(void*)*source->size); |
636 if (source->size > 0) { |
| 637 dest->size += source->size; |
637 memcpy(&dest->data[dest->size], source->data, |
| |
638 sizeof(void*)*source->size); |
| |
639 dest->size += source->size; |
| |
640 } |
| 638 |
641 |
| 639 // transfer all registered memory |
642 // transfer all registered memory |
| 640 memcpy(&dest->registered[dest->registered_size], source->registered, |
643 if (source->registered_size > 0) { |
| 641 sizeof(struct cx_mempool_foreign_memory_s) * source->size); |
644 memcpy(&dest->registered[dest->registered_size], source->registered, |
| 642 dest->registered_size += source->registered_size; |
645 sizeof(struct cx_mempool_foreign_memory_s) |
| |
646 * source->registered_size); |
| |
647 dest->registered_size += source->registered_size; |
| |
648 } |
| 643 |
649 |
| 644 // register the old allocator with the new pool |
650 // register the old allocator with the new pool |
| 645 // we have to remove const-ness for this, but that's okay here |
651 // we have to remove const-ness for this, but that's okay here |
| 646 // also register the base allocator, s.t. the pool knows how to free it |
652 // also register the base allocator, s.t. the pool knows how to free it |
| 647 CxAllocator *transferred_allocator = (CxAllocator*) source->allocator; |
653 CxAllocator *transferred_allocator = (CxAllocator*) source->allocator; |