[Spice-devel] [vdagent-win PATCH v12 3/6] Write code to decode PNG format

Frediano Ziglio fziglio at redhat.com
Tue Jul 25 18:01:18 UTC 2017


> 
> On Mon, Jul 24, 2017 at 01:39:35PM +0100, Frediano Ziglio wrote:
> > +size_t PngCoder::convert_to_dib(uint8_t *out_buf, const uint8_t *data,
> > size_t size)
> > +{
> [...]
> > +    const unsigned int width = png_get_image_width(png, info);
> > +    const unsigned int height = png_get_image_height(png, info);
> > +    const size_t stride = compute_dib_stride(width, out_bits);
> > +    const size_t image_size = stride * height;
> > +    const int palette_colors = [=]() {
> 
> If you want to use a function, then give it a name, if you don't want to
> use a function, then this can just go in convert_to_dib() body rather
> than through a lambda (I know the latter means removing the 'const').

Lambdas are functions.
I personally think the purpose of that code was clear even without
a name.
Using a "standard" function requires to declare parameters and pass
them manually, something that lambda capture can do automatically.

> 
> Christophe
> 

By the way, got new version with more old style code.

Frediano


More information about the Spice-devel mailing list