freemint / tos.hyp

The tos.hyp tries to document all functions from TOS. It also has information about MagiC, N.AES, MyAES, Geneva, XaAES, oAESis and some emulators.
https://freemint.github.io/tos.hyp
GNU General Public License v2.0
13 stars 11 forks source link

Error in Malloc description #172

Open skaftetryne opened 1 month ago

skaftetryne commented 1 month ago

One should never rely on the number of bytes actually allocated corresponding to the number requested.

The number of bytes allocated is guaranteed to be the same (or more? I guess it's rounded up to the page size when MP is enabled?) as requested, Malloc will return null if not.

mikrosk commented 1 month ago

Yes, I guess that's the idea behind that phrasing. Do you think it needs rewording?

skaftetryne commented 1 month ago

I think it should be removed, as it serves no other purpose than to confuse. Malloc is guaranteed to either return a pointer to a memory block of at least the requested size, or to fail. If the actual size of the block is larger than requested it does not matter - there is no way to know exactly how big it is. You only know that it's big enough.