[Spice-devel] [PATCH spice-gtk v2] Prefer g_new() over spice_new()
Victor Toso
victortoso at redhat.com
Thu Aug 10 13:17:42 UTC 2017
Hi,
On Thu, Aug 10, 2017 at 12:05:29PM +0200, marcandre.lureau at redhat.com wrote:
> 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>
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
> src/channel-display-gst.c | 8 ++++----
> src/channel-display-mjpeg.c | 6 +++---
> src/channel-display.c | 4 ++--
> 3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
> index d7f47d1..f978602 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;
> @@ -95,7 +95,7 @@ static void free_gst_frame(SpiceGstFrame *gstframe)
> if (gstframe->sample) {
> gst_sample_unref(gstframe->sample);
> }
> - free(gstframe);
> + g_free(gstframe);
> }
>
>
> @@ -474,7 +474,7 @@ static void spice_gst_decoder_destroy(VideoDecoder *video_decoder)
> }
> g_queue_free(decoder->display_queue);
>
> - free(decoder);
> + g_free(decoder);
>
> /* Don't call gst_deinit() as other parts of the client
> * may still be using GStreamer.
> @@ -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..f0d55f6 100644
> --- a/src/channel-display-mjpeg.c
> +++ b/src/channel-display-mjpeg.c
> @@ -294,7 +294,7 @@ static void mjpeg_decoder_destroy(VideoDecoder* video_decoder)
> g_queue_free(decoder->msgq);
> jpeg_destroy_decompress(&decoder->mjpeg_cinfo);
> g_free(decoder->out_frame);
> - free(decoder);
> + g_free(decoder);
> }
>
> G_GNUC_INTERNAL
> @@ -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..4c570ea 100644
> --- a/src/channel-display.c
> +++ b/src/channel-display.c
> @@ -1511,14 +1511,14 @@ 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);
> frame->data_opaque = in;
> frame->ref_data = (void*)spice_msg_in_ref;
> frame->unref_data = (void*)spice_msg_in_unref;
> - frame->free = (void*)free;
> + frame->free = (void*)g_free;
> if (!st->video_decoder->queue_frame(st->video_decoder, frame, latency)) {
> destroy_stream(channel, op->id);
> report_invalid_stream(channel, op->id);
> --
> 2.14.0.1.geff633fa0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170810/ad39e914/attachment-0001.sig>
More information about the Spice-devel
mailing list