Zsh Mailing List Archive
Messages sorted by:
Re: [PATCH 3/3] Constify two local variables.
- X-seq: zsh-workers 37259
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH 3/3] Constify two local variables.
- Date: Mon, 30 Nov 2015 16:42:10 +0000
- In-reply-to: <20151130155945.GD10968@tarsus.local2>
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <20151130032153.GH2504@tarsus.local2> <email@example.com> <20151130155945.GD10968@tarsus.local2>
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: