Skip to content

Commit

Permalink
[Docs] Update diagram & wording for pointer API changes.
Browse files Browse the repository at this point in the history
Follow-up to #3080, updating the
diagram and some wording to match the new UnsafePointer APIs.

MODULAR_ORIG_COMMIT_REV_ID: 01d145d8a4dbba6471fc03dd199d7bdad6fcd3c3
  • Loading branch information
arthurevans authored and modularbot committed Jun 21, 2024
1 parent 19fd489 commit 2c48a59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Binary file modified docs/manual/images/pointer-lifecycle-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/manual/images/pointer-lifecycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 8 additions & 9 deletions docs/manual/pointers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,17 @@
"\n",
"### Initializing the pointee\n",
"\n",
"The `unsafe_pointer` module includes a number of free functions for working with\n",
"the `UnsafePointer` type. To initialize allocated memory, you can use the \n",
"To initialize allocated memory, `UnsafePointer` provides the\n",
"[`init_pointee_copy()`](/mojo/stdlib/memory/unsafe_pointer/UnsafePointer#init_pointee_copy)\n",
"or [`init_pointee_move()`](/mojo/stdlib/memory/unsafe_pointer/UnsafePointer#init_pointee_move)\n",
"functions:\n",
"and [`init_pointee_move()`](/mojo/stdlib/memory/unsafe_pointer/UnsafePointer#init_pointee_move)\n",
"methods. For example:\n",
"\n",
"```mojo\n",
"ptr.init_pointee_copy(5)\n",
"ptr.init_pointee_copy(my_value)\n",
"```\n",
"\n",
"To move a value into the pointer's memory location, use\n",
"`init_pointee_move`:\n",
"`init_pointee_move()`:\n",
"\n",
"```mojo\n",
"str_ptr.init_pointee_move(my_string^)\n",
Expand Down Expand Up @@ -381,20 +380,20 @@
"\n",
"The \n",
"[`take_pointee()`](/mojo/stdlib/memory/unsafe_pointer/UnsafePointer#take_pointee)\n",
"function moves the pointee from the memory location pointed to by `ptr`. This is\n",
"method moves the pointee from the memory location pointed to by `ptr`. This is\n",
"a consuming move—it invokes `__moveinit__()` on the destination value. It leaves\n",
"the memory location uninitialized.\n",
"\n",
"The [`destroy_pointee()`](/mojo/stdlib/memory/unsafe_pointer/UnsafePointer#destroy_pointee)\n",
"function calls the destructor on the pointee, and leaves the memory location\n",
"method calls the destructor on the pointee, and leaves the memory location\n",
"pointed to by `ptr` uninitialized. \n",
"\n",
"Both `take_pointee()` and `destroy_pointee()` require that the pointer is \n",
"non-null, and the memory location contains a valid, initialized value of the \n",
"pointee's type; otherwise the function results in undefined behavior.\n",
"\n",
"The [`move_pointee_into(self, dst)`](/mojo/stdlib/memory/unsafe_pointer/UnsafePointer#move_pointee_into)\n",
"function moves the pointee from one pointer location to another. Both pointers\n",
"method moves the pointee from one pointer location to another. Both pointers\n",
"must be non-null. The source location must contain a valid, initialized value of \n",
"the pointee's type, and is left uninitialized after the call. The destination \n",
"location is assumed to be uninitialized—if it contains a valid value, that\n",
Expand Down

0 comments on commit 2c48a59

Please sign in to comment.