Skip to content
academia.sh

Unit 01 of 03

Pointers

Taking an address and accessing the pointed-to value, pointer arithmetic advancing in elements, an array decaying to a pointer, null and dangling pointers, hiding a type behind opaque pointers, and callbacks through function pointers — each together with the question of who owns the memory being pointed to.

Published Updated

Lessons

  1. 01 Pointer Basics The question of who owns a block of memory; the full run of the five-file measurement core and the 4/4/3/2 distribution across four classes (language, caller, callee, unowned), followed by measuring the address-of and dereference operators without printing an address. 13 min read
  2. 02 Pointer Arithmetic Why incrementing a pointer, decrementing it, and subtracting two pointers operates in elements rather than bytes; why an arithmetic that runs past the bounds is never run. 3 min read
  3. 03 Arrays and Pointers How an array's name decays into the address of its first element when it is passed to a function; why that decay loses the length information; and how ownership of a dynamically allocated array passes to the caller. 12 min read
  4. 04 Null and Dangling Pointers Why a null pointer is a checkable condition, while a dangling pointer keeps pointing at a freed block and is therefore never run; how both are two faces of the unowned class. 13 min read
  5. 05 `void` and Opaque Pointers How a void pointer deliberately hides the type it points to, and how an opaque type hides its contents entirely, keeping ownership inside the callee module. 13 min read
  6. 06 Function Pointers Pointers that point at a function itself and can be passed as a parameter to another function; the ownership of a callback's context belongs to the caller. 13 min read

Start typing to search.

↑↓ ↵ Esc navigate · open · close