Changeset 277
- Timestamp:
- Dec 10, 2002, 3:11:54 PM (18 years ago)
- Location:
- to-imperative/trunk/libp++
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/libp++/pxx_allocator.hh
r275 r277 60 60 // of memory block to be allocated 61 61 virtual size_t get_real_size (size_t _size) = 0 ; 62 // 63 // Returns (if possible) the start address of allocated block containing a 64 // pointer, otherwise returns null 65 virtual void* get_block (void* _ptr) = 0 ; 66 // 67 // The same as previous, but using block size 68 virtual void* get_block (void* _ptr, size_t _size) = 0 ; 62 69 63 70 }; -
to-imperative/trunk/libp++/pxx_default_allocator.hh
r275 r277 74 74 // of memory block to be allocated 75 75 inline size_t get_real_size (size_t _size) ; 76 // 77 // Returns (if possible) the start address of allocated block containing a 78 // pointer, otherwise returns null 79 inline void* get_block (void* _ptr) ; 80 // 81 // The same as previous, but using block size 82 inline void* get_block (void* _ptr, size_t _size) ; 76 83 77 84 }; -
to-imperative/trunk/libp++/pxx_default_allocator.ih
r275 r277 66 66 } 67 67 68 // 69 // Returns (if possible) the start address of allocated block containing a 70 // pointer, otherwise returns null 71 inline void* DefaultAllocator::get_block (void* _ptr) 72 { 73 if (allocator == null) set(default_malloc_allocator); 74 return allocator->get_block(_ptr); 75 } 76 77 // 78 // The same as previous, but using block size 79 inline void* DefaultAllocator::get_block (void* _ptr, size_t _size) 80 { 81 if (allocator == null) set(default_malloc_allocator); 82 return allocator->get_block(_ptr, _size); 83 } 84 68 85 inline Allocator& DefaultAllocator::get () 69 86 { -
to-imperative/trunk/libp++/pxx_heap_allocator.hh
r275 r277 129 129 inline size_t get_size (void* _ptr) ; 130 130 // 131 // Returns (if possible) the start address of allocated block containing a 132 // pointer, otherwise returns null 133 inline void* get_block (void* _ptr) ; 134 // 135 // The same as previous, but using block size 136 inline void* get_block (void* _ptr, size_t _size) ; 137 // 131 138 // Dump memory map 132 139 void memory_dump () ; -
to-imperative/trunk/libp++/pxx_heap_allocator.ih
r275 r277 95 95 } 96 96 97 // 98 // Returns (if possible) the start address of allocated block containing a 99 // pointer, otherwise returns null 100 inline void* HeapAllocator::get_block (void* _ptr) 101 { 102 size_t s = current_size; 103 while (s >= min_free_size) { 104 void* p = 105 ptr_add_offset(start_addr, ptr_sub(_ptr, start_addr) & (~(s - 1))); 106 if (((BlockHeader*)p)->size == (s | 0x01)) 107 return ptr_add_offset(p, sizeof(uintptr_t)); 108 s >>= 1; 109 } 110 return null; 111 } 112 113 // 114 // The same as previous, but using block size 115 inline void* HeapAllocator::get_block (void* _ptr, size_t _size) 116 { 117 _size += sizeof(uintptr_t); 118 if (_size < min_free_size) _size = min_free_size ; 119 _size = exps_of_two[get_order(_size)]; 120 void* real_block = 121 ptr_add_offset(start_addr, ptr_sub(_ptr, start_addr) & (~(_size - 1))); 122 return ptr_add_offset(real_block, sizeof(uintptr_t)); 123 } 124 97 125 } 98 126 -
to-imperative/trunk/libp++/pxx_malloc_allocator.hh
r275 r277 59 59 // of memory block to be allocated 60 60 inline size_t get_real_size (size_t _size) ; 61 // 62 // Returns (if possible) the start address of allocated block containing a 63 // pointer, otherwise returns null 64 inline void* get_block (void* _ptr) ; 65 // 66 // The same as previous, but using block size 67 inline void* get_block (void* _ptr, size_t _size) ; 61 68 }; 62 69 -
to-imperative/trunk/libp++/pxx_malloc_allocator.ih
r276 r277 71 71 } 72 72 73 // 74 // Returns (if possible) the start address of allocated block containing a 75 // pointer, otherwise returns null 76 inline void* MallocAllocator::get_block (void*) 77 { 78 return null; 79 } 80 81 // 82 // The same as previous, but using block size 83 inline void* MallocAllocator::get_block (void*, size_t) 84 { 85 return null; 86 } 87 73 88 } 74 89
Note: See TracChangeset
for help on using the changeset viewer.