[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Are there some potential problems if I use a self-defined memory acquirement function instead of realloc(3) in the l_alloc function?
- From: Andrew Gierth <andrew@...>
- Date: Wed, 12 Aug 2020 06:43:27 +0100
>>>>> "Philippe" == Philippe Verdy <firstname.lastname@example.org> writes:
Philippe> Which standard? In C/C++ or Lua?
The C standard says that realloc() is allowed to fail (regardless of the
relative sizes of the old and new blocks), and moreover that if it does
fail, the original block is unchanged and is still valid.
The application always has the option of just using the original block
pointer after a realloc failed to shrink the block - but the realloc
failure is an indication to the application that no memory was actually