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

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



Bart Schaefer wrote on Tue, Dec 01, 2015 at 17:11:21 -0800:
> On Dec 2, 12:36am, Daniel Shahaf wrote:
> } Subject: Re: [PATCH 3/3] Constify two local variables.
> }
> }     #define N (sizeof(void*) * arrlen(vals))
> }     vals = getfn()
> }     munge_in_place(vals)
> }     dummy = zalloc(N)
> }     memcpy(dummy, vals, N)
> }     setfn(dummy)
> 
> Would that memcpy() really work, or would it need to be zarrdup() to copy
> each of the elements as well?  Because e.g. arrsetfn() does freearray().

I think it would work, because setarrvalue() in HEAD calls freearray()
on the values array, implying that the individual elements are already
permanently allocated.

---

In the meantime I've found a reproducible invalid free() with this
patchset (reproducible by invoking _gnu_generic on ": Sr<TAB>" in the
source tree).  I haven't investigated yet.

Daniel



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