lua-users home
lua-l archive

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


Lua relies on the behaviour that the realloc-like function
>does not return a different pointer (copy) for shrinking an existing
>block.
What problems may occur if this rule(or advice) is broken?
Furthermore, realloc(3) provided by stand C does not guarantee it and
realloc(3) returns a different address indeed even if shrinking the
memory(for details, see
https://groups.google.com/g/comp.std.c/c/dKkZ1qG10Hk?pli=1).
S

On Tue, Aug 11, 2020 at 10:19 AM 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
>
> >Lua relies on the behaviour that the realloc-like function
> >does not return a different pointer (copy) for shrinking an existing
> >block.
> What problems may occur if this rule(or advice) is broken?
>
> On Mon, Aug 10, 2020 at 8:34 PM Stefan <ste@evelance.de> wrote:
> >
> > Am 10.08.2020 um 10:32 schrieb 孙世龙 sunshilong:
> > > Hi, list
> > >
> > > I want to use a self-defined memory acquirement function instead of
> > > using realloc(3) in the l_alloc function.
> > > Since I am a newbie, I don't know if there are some potential problems.
> > > Could somebody shed some light on this problem?
> > > Thank you for your attention to this matter.
> >
> > I think Lua relies on the behaviour that the realloc-like function
> > does not return a different pointer (copy) for shrinking an existing
> > block. Maybe that could be a problem for some allocators.