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

Discussion

Comparing a driver that owns its buffer with one that takes a buffer from the caller, the caller-supplied form

  • A.removes the need for the driver to know the length
  • B.guarantees that no data can be lost
  • C.avoids a copy and lets the caller control the memory
  • D.is always simpler for the caller to use

Answer: C

Passing a pointer and a length lets the application place the buffer where it chooses and saves the driver copying into and out of its own. The cost is that ownership and lifetime become the caller's responsibility, which has to be documented.

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

Post your comment

Please log in or register to post a comment.