Machine-translated by Google. Questions are authored in English.
Top

Discussion

Placing a table of function pointers in const memory is worthwhile because it

  • A.puts the table in flash and protects it from a stray write
  • B.makes the calls through it faster to execute
  • C.allows the table to be modified at run time
  • D.removes the need for the pointers to be initialised

Answer: A

Correct answer: puts the table in flash and protects it from a stray write

Marking the table const lets the linker place it in flash, saving scarce RAM, and a wild pointer writing to it then faults or is simply ignored rather than corrupting the dispatch. The calls through it are no faster; the gains are memory and robustness.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.