lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 2020-08-11 at 11:49 +0800, 孙世龙 sunshilong wrote:
> 
> >What matters is what the language
> >standards say, and what they say is that realloc() is permitted to fail
> >when shrinking a block. (Some realloc implementations never fail in that
> >case, but many in common use do.)
> Could you please please give me some references or documents for me to
> go through?
> What about malloc(3) provided by the stand C library?

There is no such thing as _the_ malloc(3) provided by _the_
standard C library. That's the very point.

It doesn't matter what the specific setup that you happen to use
locally happens to do in this specific version and configuration
on this specific platform that you use today. You just cannot
rely on any of these local details unless they officially are
granted to you. Which they aren't in this case.

And even if you see a specific implementation dependent behaviour
today in your local setup, you still cannot rely on it to be
present tomorrow in another version of this very software or in a
different configuration on that platform of yours or on another
platform with the same version and configuration of the software
component.

Or as an alternative: Remain aware that you rely on something
that you were not given. And accept when your assumption doesn't
hold. This can be as valid as sticking to portable code, just
needs to be done consciously. Your decision.


virtually yours
Gerhard Sittig
-- 
     If you don't understand or are scared by any of the above
             ask your parents or an adult to help you.