On 10/27/26 08:00, James Kuyper wrote:
> On 2026-10-26 17:45, Lawrence D’Oliveiro wrote:
>> On Mon, 26 Oct 2026 13:26:38 -0700, Chris M. Thomasson wrote:
> [restore snippage]>> On 2026-10-25 23:39, Lawrence D’Oliveiro wrote:
>>>> On Sun, 25 Oct 2026 19:11:48 -0700, Chris M. Thomasson wrote: >>>>
>>>>> A caller provided buffer is normal with a lot of API's out there.
>>>> >>>> No it isn’t. It’s not a good way to manage things, anyway: instead of >>>> solving the resource-allocation problem once and for all in the >>>> library API, you are pushing the burden onto all the client code, each >>>> one of which has to solve it for itself. >>>> >>>> That’s a dumb way to design things.
>
>>> HUH? How do you call say, fread without a user provided buffer?
>> >> Relevance being?
> > fread() uses a caller-provided buffer, which, according to your previous > comment, "push[es] the burden onto all the client code, each one of > which has to solve it for itself", so according to you, "That's a dumb > way to design things"..If that isn't your actual opinion of fread(), > your comments need to be at least a little more nuanced to avoid > applying to fread().
The difference is that the size of the buffer for fread() is the maximum you want/expect to read. The size of an object is the size it is, not necessarily what you expect. If you don't provide enough space you will truncate.