From 0c7208c12e85a874c6f45f3fb0d5259287c55ce7 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 28 Jul 2022 17:17:33 -0700 Subject: [PATCH] remove dead code --- crates/libs/windows/src/core/heap.rs | 30 ---------------------------- 1 file changed, 30 deletions(-) diff --git a/crates/libs/windows/src/core/heap.rs b/crates/libs/windows/src/core/heap.rs index 791c10f96d..5a56717f2e 100644 --- a/crates/libs/windows/src/core/heap.rs +++ b/crates/libs/windows/src/core/heap.rs @@ -37,33 +37,3 @@ pub unsafe fn heap_free(ptr: *mut core::ffi::c_void) { HeapFree(heap, HEAP_NONE, ptr); } } - -/// Copy len elements of an iterator of type `T` into a freshly allocated buffer. -/// -/// Returns a pointer to the beginning of the buffer. This pointer must be freed when done using `heap_free`. -/// -/// # Panics -/// -/// This function panics if the heap allocation fails, the alignment requirements of 'T' surpass -/// 8 (HeapAlloc's alignment). -pub fn alloc_from_iter(iter: I, len: usize) -> *const T -where - I: Iterator, - T: Copy, -{ - // alignment of memory returned by HeapAlloc is at least 8 - // Source: https://docs.microsoft.com/en-us/windows/win32/api/heapapi/nf-heapapi-heapalloc - // Ensure that T has sufficient alignment requirements - assert!(std::mem::align_of::() <= 8, "T alignment surpasses HeapAlloc alignment"); - - let ptr = heap_alloc(len * std::mem::size_of::()).expect("could not allocate string") as *mut T; - - for (offset, c) in iter.take(len).enumerate() { - // SAFETY: ptr points to an allocation object of size `len`, indices accessed are always lower than `len` - unsafe { - ptr.add(offset).write(c); - } - } - - ptr -}