3 ms·
To be fair, without knowing what that API does, I could see a situation where it itself doesn't know how long the data would be. This was to get a message out
by stcredzero 10y ago
To be fair, without knowing what that API does, I could see a situation where it itself doesn't know how long the data would be.
This was to get a message out of the API. At the point one is making the call, it does know how long the message is. (Having already gotten a callback.) It looks like the author forgot to write the function that would return the length, then improvised.
Furthermore, the API probably doesn't want to allocate and buffer the data itself since it could be very long, nor does it want to impose a fixed limit since the application should decide that.
This was probably the case.