Changeset 282
- Timestamp:
- Dec 10, 2002, 8:11:14 PM (18 years ago)
- Location:
- to-imperative/trunk/libp++
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/libp++/pxx_chunk_allocator.hh
r280 r282 89 89 90 90 91 Allocator& block_allocator ;91 Allocator& allocator ; 92 92 93 93 BlockHeader block_list ; -
to-imperative/trunk/libp++/pxx_chunk_allocator.ih
r280 r282 57 57 Allocator& _allocator /* = default_allocator */ 58 58 ) : 59 block_allocator (_allocator),59 allocator (_allocator), 60 60 block_list (&block_list, &block_list), 61 61 chunk_size (size_align(sizeof(type_t), 2 * sizeof(void*))), … … 75 75 Allocator& _allocator /* = default_allocator */ 76 76 ) : 77 block_allocator (_allocator),77 allocator (_allocator), 78 78 block_list (&block_list, &block_list), 79 79 chunk_size (size_align(sizeof(type_t), 2 * sizeof(void*))), … … 84 84 _allocator.get_real_size(_nchunks * chunk_size + sizeof(BlockHeader)); 85 85 printf("block_size: %u\n", block_size); 86 printf("features: %08x\n", allocator.get_features()); 86 87 nchunks = (block_size - sizeof(BlockHeader))/chunk_size; 87 88 } … … 94 95 void* q = p; 95 96 p = p->next; 96 block_allocator.deallocate(q);97 allocator.deallocate(q); 97 98 } 98 99 } … … 108 109 return (type_t*)p; 109 110 } else { 110 BlockHeader* p = (BlockHeader*) block_allocator.allocate(block_size);111 BlockHeader* p = (BlockHeader*)allocator.allocate(block_size); 111 112 //printf("Allocated block at %p\n", p); 112 113 init_block(p); … … 213 214 //printf("Deallocating block at %p\n", b); 214 215 b->remove(); 215 root = node_remove(root, b); 216 block_allocator.deallocate(b); 216 if ((allocator.get_features() & ALLOCATOR_HAS_GET_BLOCK_WITH_SIZE) == 0) { 217 root = node_remove(root, b); 218 } 219 allocator.deallocate(b); 217 220 } 218 221 } … … 221 224 inline BlockHeader* ChunkAllocator<type_t>::get_block (void* _ptr) 222 225 { 223 void* p = block_allocator.get_block(_ptr, block_size);224 if (p != null) return (BlockHeader*)p;225 else {226 if ((allocator.get_features() & ALLOCATOR_HAS_GET_BLOCK_WITH_SIZE) != 0) { 227 return (BlockHeader*)(allocator.get_block(_ptr, block_size)); 228 } else { 226 229 BlockHeader* node = root; 227 230 do { … … 370 373 p->next = &free_list; 371 374 free_list.prev = p; 372 {375 if ((allocator.get_features() & ALLOCATOR_HAS_GET_BLOCK_WITH_SIZE) == 0) { 373 376 _ptr->left = _ptr->right = null; 374 377 _ptr->balance = 0;
Note: See TracChangeset
for help on using the changeset viewer.