Hrvoje Niksic <hniksic(a)srce.hr> writes:
> Gunnar Evermann <ge204(a)eng.cam.ac.uk> writes:
>
> > Is there any particular reason for this rather obvious lie ('This
> > function can GC') at insdel.c:2644?
> >
> > ---------------
> > Charcount
> > buffer_insert_from_buffer_1 (struct buffer *buf, Bufpos pos,
> > struct buffer *buf2, Bufpos pos2,
> > Charcount length, int flags)
> > {
> > /* This function can GC */
> > Lisp_Object str = make_string_from_buffer (buf2, pos2, length);
> > return buffer_insert_string_1 (buf, pos, 0, str, 0,
> > XSTRING_LENGTH (str), flags);
> > }
>
> That's no lie. buffer_insert_string_1() can not only GC, but invoke
> arbitrary Lisp code! Remember {before,after}-change-functions.
I know. Maybe I misunderstood all those 'can GC'-comments. I assumed
them to mean:
- during execution of this functions Lisp code might be called and
potentially GC can occur
- this code is GC-safe, meaning it GCPROs all local Lisp_Objects and
therefore a GC won't collect vital stuff.
My question was basically why we don't GCPRO 'str' and then use
RETURN_GCPRO, to ensure the second point.
Sorry for the confusion.
Gunnar
--
Gunnar Evermann
Speech, Vision & Robotics Group
Engineering Department
Cambridge University