Change in ...osmo-mgw[master]: mgcp_codec: split codec_free() off of codec_init()

neels gerrit-no-reply at lists.osmocom.org
Fri Aug 9 00:38:14 UTC 2019


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/15132


Change subject: mgcp_codec: split codec_free() off of codec_init()
......................................................................

mgcp_codec: split codec_free() off of codec_init()

Both are used only in the same .c file, so make them static.

Preparation to fix a memleak in a conn's codec list.

Change-Id: I120cab0a352a1e7b31c8f9c720c47b2c291311d7
---
M src/libosmo-mgcp/mgcp_codec.c
1 file changed, 14 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/32/15132/1

diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c
index d5b99e8..4c14d12 100644
--- a/src/libosmo-mgcp/mgcp_codec.c
+++ b/src/libosmo-mgcp/mgcp_codec.c
@@ -76,18 +76,24 @@
 }
 
 /* Initalize or reset codec information with default data. */
-void codec_init(struct mgcp_rtp_codec *codec)
+static void codec_init(struct mgcp_rtp_codec *codec)
+{
+	*codec = (struct mgcp_rtp_codec){
+		.payload_type = -1,
+		.frame_duration_num = DEFAULT_RTP_AUDIO_FRAME_DUR_NUM,
+		.frame_duration_den = DEFAULT_RTP_AUDIO_FRAME_DUR_DEN,
+		.rate = DEFAULT_RTP_AUDIO_DEFAULT_RATE,
+		.channels = DEFAULT_RTP_AUDIO_DEFAULT_CHANNELS,
+	};
+}
+
+static void codec_free(struct mgcp_rtp_codec *codec)
 {
 	if (codec->subtype_name)
 		talloc_free(codec->subtype_name);
 	if (codec->audio_name)
 		talloc_free(codec->audio_name);
-	memset(codec, 0, sizeof(*codec));
-	codec->payload_type = -1;
-	codec->frame_duration_num = DEFAULT_RTP_AUDIO_FRAME_DUR_NUM;
-	codec->frame_duration_den = DEFAULT_RTP_AUDIO_FRAME_DUR_DEN;
-	codec->rate = DEFAULT_RTP_AUDIO_DEFAULT_RATE;
-	codec->channels = DEFAULT_RTP_AUDIO_DEFAULT_CHANNELS;
+	*codec = (struct mgcp_rtp_codec){};
 }
 
 /*! Initalize or reset codec information with default data.
@@ -229,7 +235,7 @@
 	return 0;
 error:
 	/* Make sure we leave a clean codec entry on error. */
-	codec_init(codec);
+	codec_free(codec);
 	memset(codec, 0, sizeof(*codec));
 	return -EINVAL;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/15132
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I120cab0a352a1e7b31c8f9c720c47b2c291311d7
Gerrit-Change-Number: 15132
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190809/679d61d2/attachment.html>


More information about the gerrit-log mailing list