IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

unsafe_destroy_n

def unsafe_destroy_n[T: Deinitable](pointer: Pointer[T], count: Int)

Destroy count initialized values at pointer.

This function runs the destructor for each of the count values, leaving the memory uninitialized.

For types with trivial destructors, this is a no-op and generates no code. Otherwise, it calls unsafe_deinit_pointee() on each element.

Safety:

  • pointer must point to a valid memory region containing at least count initialized elements of type T.
  • After this call, the values at pointer[0:count] are uninitialized and must not be read or destroyed again until re-initialized.

Parameters:

  • ​T (Deinitable): The type of values to destroy, which must be Deinitable.

Args:

  • ​pointer (Pointer[T]): Pointer to the memory region containing values to destroy.
  • ​count (Int): The number of elements to destroy.