[Spice-devel] [PATCH spice-gtk 1/2] display: factor out initialization of stream array

Christophe Fergeau cfergeau at redhat.com
Mon Jul 17 11:06:50 UTC 2017


On Mon, Jul 17, 2017 at 01:04:04PM +0200, Victor Toso wrote:
> Hi,
> 
> On Mon, Jul 17, 2017 at 12:52:41PM +0200, Christophe Fergeau wrote:
> > On Fri, Jun 30, 2017 at 12:51:16PM +0200, Victor Toso wrote:
> > > From: Victor Toso <me at victortoso.com>
> > > 
> > > Including some comment about current implementation of stream-id value
> > > in the Spice.
> > > 
> > > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > > ---
> > >  src/channel-display.c | 42 +++++++++++++++++++++++++++++++-----------
> > >  1 file changed, 31 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/src/channel-display.c b/src/channel-display.c
> > > index 06c503c..9ae2851 100644
> > > --- a/src/channel-display.c
> > > +++ b/src/channel-display.c
> > > @@ -105,6 +105,7 @@ static void channel_set_handlers(SpiceChannelClass *klass);
> > >  
> > >  static void clear_surfaces(SpiceChannel *channel, gboolean keep_primary);
> > >  static void clear_streams(SpiceChannel *channel);
> > > +static void streams_check_init(SpiceChannel *channel, guint stream_id);
> > >  static display_surface *find_surface(SpiceDisplayChannelPrivate *c, guint32 surface_id);
> > >  static void spice_display_channel_reset(SpiceChannel *channel, gboolean migrating);
> > >  static void spice_display_channel_reset_capabilities(SpiceChannel *channel);
> > > @@ -1233,17 +1234,7 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
> > >  
> > >      CHANNEL_DEBUG(channel, "%s: id %u", __FUNCTION__, op->id);
> > >  
> > > -    if (op->id >= c->nstreams) {
> > > -        int n = c->nstreams;
> > > -        if (!c->nstreams) {
> > > -            c->nstreams = 1;
> > > -        }
> > > -        while (op->id >= c->nstreams) {
> > > -            c->nstreams *= 2;
> > > -        }
> > > -        c->streams = realloc(c->streams, c->nstreams * sizeof(c->streams[0]));
> > > -        memset(c->streams + n, 0, (c->nstreams - n) * sizeof(c->streams[0]));
> > > -    }
> >
> > What about making this g_array_set_size(c->streams, op->id);?
> >
> > Christophe
> 
> You mean by making c->streams from display_stream** to a GArray or
> GPtrArray? Yes, I think it would be better too.

Yes, this is what I meant.

Christohpe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170717/ee1949fd/attachment.sig>


More information about the Spice-devel mailing list