aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>2012-08-21 17:19:05 +0000
committermartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>2012-08-21 17:19:05 +0000
commitccb6814b0968b9cf1e654a60020fb2b0a2eabae8 (patch)
tree0e6172788d33ce58d316ddc62cd579d74abf10e5
parentc3b00edbda502c7c8031309ef98c4da4842ec499 (diff)
Avoid some calls to strlen() by remembering return value from
g_strlcpy(). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@44608 f5534014-38df-0310-8fa8-9805f1628bb7
-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;