neels has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-mgw/+/33535
)
Change subject: mgcp_client: tweak extract_codec_name() implementation
......................................................................
mgcp_client: tweak extract_codec_name() implementation
Instead of calling strlen() for every loop iteration, just use strchr()
to find the position of '/'.
Change-Id: Ifc7302b6c5f9288a622e33c3e8b5fe0e7037dbdc
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/35/33535/1
diff --git a/src/libosmo-mgcp-client/mgcp_client.c
b/src/libosmo-mgcp-client/mgcp_client.c
index 75c7b14..78652a1 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -69,17 +69,16 @@
static char *extract_codec_name(const char *str)
{
static char buf[64];
- unsigned int i;
+ char *pos;
if (!str)
return NULL;
osmo_strlcpy(buf, str, sizeof(buf));
- for (i = 0; i < strlen(buf); i++) {
- if (buf[i] == '/')
- buf[i] = '\0';
- }
+ pos = strchr(buf, '/');
+ if (pos)
+ *pos = '\0';
return buf;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-mgw/+/33535
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifc7302b6c5f9288a622e33c3e8b5fe0e7037dbdc
Gerrit-Change-Number: 33535
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange