[PATCH] screenshooter: Properly handle multiple outputs.
Jonas Ådahl
jadahl at gmail.com
Thu Apr 5 03:08:47 PDT 2012
On Thu, Apr 5, 2012 at 11:42 AM, Andreas Ericsson <ae at op5.se> wrote:
> On 04/04/2012 02:37 PM, Kristian Hoegsberg wrote:
>> On Wed, Apr 04, 2012 at 01:51:08AM -0600, Scott Moreau wrote:
>>> ---
>>
>>>
>>> - write_png(output_width, output_height, data);
>>> + write_png(ss_area_width, ss_area_height, data);
>>> +
>>> + wl_list_for_each(ss_output,&output_list, link) {
>>> + free(ss_output);
>>
>> You need wl_list_for_each_safe here since you're freeing the structs
>> that holds the prev/next pointers.
>>
>
> Is there a point to having two different ones? The compiler still
> generates code to stash the next and prev pointers, so any difference
> in execution time should be microscopic, if it exists at all, and the
> possibility of using the wrong one is obviously very real.
With wl_list_for_each, iterating over a list of 'struct foo' you need
only declare one such struct. With wl_list_for_each_safe you also need
to declare a "tmp" one.
As a side-effect it can be easier to read since one can assume that
when using the _safe version the item may be destroyed, while using
the plain version, it's means that the item will not be destroyed.
Except if someone uses it incorrectly of course.
Jonas
More information about the wayland-devel
mailing list