rchd: say how long lent bytes have to live

rchd_feed_borrow said lent bytes had to outlive every rchd_read_step()
that returned RCHD_PENDING. The decoder is done with them sooner: once
it has decoded the hunk, which is before it asks for the next range.
Spell that out, so a caller without a mapping can lend one staging
buffer per request and refill it for the next instead of paying for
rchd_feed_at()'s copy, and say that lent bytes are used once.

Documentation only; the decoder already behaves this way.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-10-28 21:03:44 +01:00
1 parent 820818936c
commit fd2d330cfe
1 file changed
+6 -2
+6 -2
View File
@@ -572,8 +572,12 @@ int rchd_feed_at(rchd_t *chd, uint64_t offset, int source,
* hunk, and at the maximum hunk size that is half a megabyte of
* memcpy the caller has already paid for once.
*
* @data must stay valid and unmoved until the next rchd_read_step()
* returns something other than RCHD_PENDING. That rules out any buffer
* @data must stay valid and unmoved until the decoder is done with
* it: until a later rchd_read_step() either finishes the read (returns
* something other than RCHD_PENDING) or asks for a different range. A
* caller may therefore lend one staging buffer per request and refill
* it for the next one. Lent bytes are used once; asking for the same
* range again means supplying it again. That rules out any buffer
* whose pages can be released underneath the decoder while it works,
* and it rules out a base pointer that can move: a growing arena may
* reallocate, so re-read the base after growing it and borrow from the