[Spice-devel] [PATCH spice-gtk] Prefer g_new() over spice_new()
Marc-André Lureau
marcandre.lureau at redhat.com
Thu Aug 10 09:50:14 UTC 2017
Hi
----- Original Message -----
> >
> > From: Marc-André Lureau <marcandre.lureau at redhat.com>
> >
> > spice_new() should probably be replaced by g_new() in all spice code
> > that depend on glib.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
>
> You have to replace also free with g_free unless you want program
> to crash depending on Glib configuration.
Right, a regular mistake. I was looking for spice_free() which we dont have.
We already mix g_malloc/new with free(). I'll resend with another patch for the rest of free() usage.
>
> > ---
> > src/channel-display-gst.c | 4 ++--
> > src/channel-display-mjpeg.c | 4 ++--
> > src/channel-display.c | 2 +-
> > 3 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
> > index d7f47d1..fa85ac2 100644
> > --- a/src/channel-display-gst.c
> > +++ b/src/channel-display-gst.c
> > @@ -82,7 +82,7 @@ typedef struct SpiceGstFrame {
> >
> > static SpiceGstFrame *create_gst_frame(GstBuffer *buffer, SpiceFrame
> > *frame)
> > {
> > - SpiceGstFrame *gstframe = spice_new(SpiceGstFrame, 1);
> > + SpiceGstFrame *gstframe = g_new(SpiceGstFrame, 1);
> > gstframe->timestamp = GST_BUFFER_PTS(buffer);
> > gstframe->frame = frame;
> > gstframe->sample = NULL;
> > @@ -595,7 +595,7 @@ VideoDecoder* create_gstreamer_decoder(int codec_type,
> > display_stream *stream)
> > g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), NULL);
> >
> > if (gstvideo_init()) {
> > - decoder = spice_new0(SpiceGstDecoder, 1);
> > + decoder = g_new0(SpiceGstDecoder, 1);
> > decoder->base.destroy = spice_gst_decoder_destroy;
> > decoder->base.reschedule = spice_gst_decoder_reschedule;
> > decoder->base.queue_frame = spice_gst_decoder_queue_frame;
> > diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c
> > index 563dc1b..cdb86ec 100644
> > --- a/src/channel-display-mjpeg.c
> > +++ b/src/channel-display-mjpeg.c
> > @@ -302,7 +302,7 @@ VideoDecoder* create_mjpeg_decoder(int codec_type,
> > display_stream *stream)
> > {
> > g_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG,
> > NULL);
> >
> > - MJpegDecoder *decoder = spice_new0(MJpegDecoder, 1);
> > + MJpegDecoder *decoder = g_new0(MJpegDecoder, 1);
> >
> > decoder->base.destroy = mjpeg_decoder_destroy;
> > decoder->base.reschedule = mjpeg_decoder_reschedule;
> > @@ -322,7 +322,7 @@ VideoDecoder* create_mjpeg_decoder(int codec_type,
> > display_stream *stream)
> > decoder->mjpeg_src.term_source = mjpeg_src_term;
> > decoder->mjpeg_cinfo.src = &decoder->mjpeg_src;
> >
> > - /* All the other fields are initialized to zero by spice_new0(). */
> > + /* All the other fields are initialized to zero by g_new0(). */
> >
> > return (VideoDecoder*)decoder;
> > }
> > diff --git a/src/channel-display.c b/src/channel-display.c
> > index 45742a6..38f07f6 100644
> > --- a/src/channel-display.c
> > +++ b/src/channel-display.c
> > @@ -1511,7 +1511,7 @@ static void display_handle_stream_data(SpiceChannel
> > *channel, SpiceMsgIn *in)
> > * decoding and best decide if/when to drop them when they are late,
> > * taking into account the impact on later frames.
> > */
> > - frame = spice_new(SpiceFrame, 1);
> > + frame = g_new(SpiceFrame, 1);
> > frame->mm_time = op->multi_media_time;
> > frame->dest = *stream_get_dest(st, in);
> > frame->size = spice_msg_in_frame_data(in, &frame->data);
>
> Frediano
>
More information about the Spice-devel
mailing list