> Date: Wed, 19 Dec 2018 16:03:08 +0000
> From: Alan Third <alan@idiocy.org>
>
> I want to strip out the properties that I’m going to use at display
> time, so that I can use the same cached image for different output
> sizes, while leaving other properties that I don’t know about in
> place. So I’d like to store the above as
>
> '(image :file "image.png" :format png)
>
> however I’m not sure how to go about filtering the list in C. I tried
> a few variations on this, but they all seg fault
>
> static Lisp_Object
> get_cache_spec (Lisp_Object spec)
> {
> Lisp_Object cache_spec, tail;
>
> cache_spec = Qnil;
>
> for (tail = XCDR (spec);
> CONSP (tail) && CONSP (XCDR (tail));
> tail = XCDR (XCDR (tail)))
> {
> if (!EQ (XCAR (tail), Qwidth)
> && !EQ (XCAR (tail), QCheight)
> && !EQ (XCAR (tail), QCmax_width)
> && !EQ (XCAR (tail), QCmax_height)
> && !EQ (XCAR (tail), QCscale)
> && !EQ (XCAR (tail), QCmargin)
> && !EQ (XCAR (tail), QCascent)
> && !EQ (XCAR (tail), QCrelief))
> cache_spec = list3 (XCAR (tail), XCAR (XCDR (tail)), cache_spec);
> }
> cache_spec = list2 (XCAR (spec), cache_spec);
I think you should use Fcons instead of list3 or list2.