aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2012-08-21 17:19:05 +0000
committerMartin Mathieson <martin.r.mathieson@googlemail.com>2012-08-21 17:19:05 +0000
commitd2b7806d3f8e85d18065bfd1639394a7de2ff54b (patch)
tree0e6172788d33ce58d316ddc62cd579d74abf10e5 /wiretap
parentf6b1932a8a9342feee671860efef45c75e73263d (diff)
Avoid some calls to strlen() by remembering return value from
g_strlcpy(). svn path=/trunk/; revision=44608
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/catapult_dct2000.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 13a99dfd5b..27c7a02798 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -1257,29 +1257,30 @@ write_stub_header(guint8 *frame_buffer, char *timestamp_string,
gchar *outhdr_name)
{
int stub_offset = 0;
+ gsize length;
- g_strlcpy((char*)frame_buffer, context_name, MAX_CONTEXT_NAME+1);
- stub_offset += (int)(strlen(context_name) + 1);
+ length = g_strlcpy((char*)frame_buffer, context_name, MAX_CONTEXT_NAME+1);
+ stub_offset += (int)(length + 1);
/* Context port number */
frame_buffer[stub_offset] = context_port;
stub_offset++;
/* Timestamp within file */
- g_strlcpy((char*)&frame_buffer[stub_offset], timestamp_string, MAX_TIMESTAMP_LEN+1);
- stub_offset += (int)(strlen(timestamp_string) + 1);
+ length = g_strlcpy((char*)&frame_buffer[stub_offset], timestamp_string, MAX_TIMESTAMP_LEN+1);
+ stub_offset += (int)(length + 1);
/* Protocol name */
- g_strlcpy((char*)&frame_buffer[stub_offset], protocol_name, MAX_PROTOCOL_NAME+1);
- stub_offset += (int)(strlen(protocol_name) + 1);
+ length = g_strlcpy((char*)&frame_buffer[stub_offset], protocol_name, MAX_PROTOCOL_NAME+1);
+ stub_offset += (int)(length + 1);
/* Protocol variant number (as string) */
- g_strlcpy((void*)&frame_buffer[stub_offset], variant_name, MAX_VARIANT_DIGITS+1);
- stub_offset += (int)(strlen(variant_name) + 1);
+ length = g_strlcpy((void*)&frame_buffer[stub_offset], variant_name, MAX_VARIANT_DIGITS+1);
+ stub_offset += (int)(length + 1);
/* Outhdr */
- g_strlcpy((char*)&frame_buffer[stub_offset], outhdr_name, MAX_OUTHDR_NAME+1);
- stub_offset += (int)(strlen(outhdr_name) + 1);
+ length = g_strlcpy((char*)&frame_buffer[stub_offset], outhdr_name, MAX_OUTHDR_NAME+1);
+ stub_offset += (int)(length + 1);
/* Direction */
frame_buffer[stub_offset] = direction;