Skip to main content

Mojo function

destroy_n

destroy_n[T: ImplicitlyDestructible](pointer: UnsafePointer[T, pointer.origin], 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 destroy_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:

Args:

  • โ€‹pointer (UnsafePointer): Pointer to the memory region containing values to destroy.
  • โ€‹count (Int): The number of elements to destroy.

Was this page helpful?