@@ -255,67 +255,6 @@ impl<'alloc> PoolAllocator<'alloc> {
255255 }
256256 }
257257
258- /// Allocates a raw slot of the given size without type constraints.
259- /// Returns a pointer to uninitialized memory.
260- ///
261- /// # Safety
262- /// Caller must initialize the memory before use and ensure proper cleanup.
263- pub fn alloc_slot_raw ( & mut self , size : usize ) -> Result < NonNull < u8 > , PoolAllocError > {
264- let sc_idx = size_class_index_for ( size) ;
265- let slot_size = SIZE_CLASSES . get ( sc_idx) . copied ( ) . unwrap_or ( size) ;
266-
267- let cached_idx = self . alloc_cache [ sc_idx] . get ( ) ;
268- if cached_idx < self . slot_pools . len ( ) {
269- let pool = & self . slot_pools [ cached_idx] ;
270- if pool. slot_size == slot_size
271- && let Some ( slot_ptr) = pool. alloc_slot ( )
272- {
273- return Ok ( slot_ptr) ;
274- }
275- }
276-
277- // try existing pools with matching slot_size first
278- for ( i, pool) in self . slot_pools . iter ( ) . enumerate ( ) . rev ( ) {
279- if pool. slot_size == slot_size
280- && let Some ( slot_ptr) = pool. alloc_slot ( )
281- {
282- self . alloc_cache [ sc_idx] . set ( i) ;
283- return Ok ( slot_ptr) ;
284- }
285- }
286-
287- // need a new pool for this size class
288- // try the recycle list first
289- if let Some ( pos) = self
290- . recycled_pools
291- . iter ( )
292- . rposition ( |p| p. slot_size == slot_size)
293- {
294- let pool = self . recycled_pools . swap_remove ( pos) ;
295- let slot_ptr = pool. alloc_slot ( ) . ok_or ( PoolAllocError :: OutOfMemory ) ?;
296- let insert_idx = self . slot_pools . len ( ) ;
297- let ( base, end) = pool. slot_range ( ) ;
298- let spos = self . sorted_ranges . partition_point ( |& ( b, _, _) | b < base) ;
299- self . sorted_ranges . insert ( spos, ( base, end, insert_idx) ) ;
300- self . slot_pools . push ( pool) ;
301- self . alloc_cache [ sc_idx] . set ( insert_idx) ;
302- return Ok ( slot_ptr) ;
303- }
304-
305- // Allocate a fresh page from the OS
306- let total = self . page_size . max ( slot_size * 4 ) ;
307- let new_pool = SlotPool :: try_init ( slot_size, total, 16 ) ?;
308- self . current_heap_size += new_pool. layout . size ( ) ;
309- let slot_ptr = new_pool. alloc_slot ( ) . ok_or ( PoolAllocError :: OutOfMemory ) ?;
310- let insert_idx = self . slot_pools . len ( ) ;
311- let ( base, end) = new_pool. slot_range ( ) ;
312- let spos = self . sorted_ranges . partition_point ( |& ( b, _, _) | b < base) ;
313- self . sorted_ranges . insert ( spos, ( base, end, insert_idx) ) ;
314- self . slot_pools . push ( new_pool) ;
315- self . alloc_cache [ sc_idx] . set ( insert_idx) ;
316- Ok ( slot_ptr)
317- }
318-
319258 /// drops the value at `ptr` and returns the slot to the allocator
320259 ///
321260 /// # Safety
0 commit comments