Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH 3/3] Constify two local variables.

On Mon, 30 Nov 2015 15:59:45 +0000
Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Peter Stephenson wrote on Mon, Nov 30, 2015 at 09:38:32 +0000:
> > On Mon, 30 Nov 2015 03:21:53 +0000
> > Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> > > I assume that v->pm->gsu.a->getfn() has no access to v->start and
> > > v->end, hence changing the order is safe.
> > 
> > Yes, the getfn() is very low level, dealing only with storage for that
> > parameter and having no knowledge at all of any expansion/substitution
> > happening above it.
> > 
> Thanks, that's what I expected.  What are the lifetime interfaces of
> getfn/setfn of arrays?

That's less well defined than it should be, but the implication is
obviously they will be used within the liftime of the current heap.
This is common in e.g. Src/Modules/parameter.c for returning parameters
reflecting some internal state.  Making sure this is what happens isn't
easy.  The only real difference from any other use of the heap is that
the source of the heap allocation is quite well buried.  But maybe
that's not much of a difference, since there's much heap allocation a
few layers above in paramsubst().

As Bart says, setfn() expects a permanently allocated values; if it
doesn't neeed it, it's up to the setfn in question to convert the value
and then free what's passed in.


Messages sorted by: Reverse Date, Date, Thread, Author