Is realloc(3) permitted to fail when shrinking a block?

Florian Weimer fw@deneb.enyo.de
Sat Aug 15 07:07:17 GMT 2020


* 孙世龙 sunshilong via Gcc-help:

> As the subject, I couldn't find any positive or negative statements
> about this matter in the Linux Programmer's Manual.
>
> Could somebody shed some light on this matter?

As a quality-of-implementation issue, I would not expect realloc to
fail when shrinking a block.  As a fallback, it can always keep the
block in its original size, not changing anything.

The C standard does not require that reducing the size cannot lead to
failure.


More information about the Gcc-help mailing list