You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/08/05 22:51:31 UTC
[2/2] git commit: TS-2097 replace ink_string_copy() w/ ink_strlcpy()
TS-2097 replace ink_string_copy() w/ ink_strlcpy()
we already have ink_strlcpy() in our reportoire, and ink_string_copy()
is only used twice. We replace those two occurances.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/17ec6c20
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/17ec6c20
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/17ec6c20
Branch: refs/heads/master
Commit: 17ec6c208ea219dbe0479c9c44649d0fc89aa3c3
Parents: ac04a76
Author: Igor Galić <i....@brainsware.org>
Authored: Mon Aug 5 22:35:57 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Mon Aug 5 22:35:57 2013 +0200
----------------------------------------------------------------------
lib/ts/ink_string.cc | 2 +-
lib/ts/ink_string.h | 29 -----------------------------
proxy/logging/LogBuffer.cc | 3 +--
3 files changed, 2 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/17ec6c20/lib/ts/ink_string.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_string.cc b/lib/ts/ink_string.cc
index 00e941e..4968676 100644
--- a/lib/ts/ink_string.cc
+++ b/lib/ts/ink_string.cc
@@ -238,7 +238,7 @@ ink_string_find_dotted_extension(char *str, char *ext, int max_ext_len)
if (p <= str)
return (NULL);
- ink_string_copy(ext, (p + 1), max_ext_len);
+ ink_strlcpy(ext, (p + 1), max_ext_len);
}
}
return (p);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/17ec6c20/lib/ts/ink_string.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_string.h b/lib/ts/ink_string.h
index 0e88634..8351fbe 100644
--- a/lib/ts/ink_string.h
+++ b/lib/ts/ink_string.h
@@ -95,35 +95,6 @@ void ink_utf8_to_latin1(const char *in, int inlen, char *out, int *outlen);
*===========================================================================*/
-/*---------------------------------------------------------------------------*
-
- char *ink_string_copy(char *dest, char *src, int n)
-
- This routine is like ink_strncpy, but it stops writing to <dest>
- after the first NUL from <src> is written, even if <n> bytes are
- not copied. A NUL is always written if n > 0. Returns <dest>.
-
- *---------------------------------------------------------------------------*/
-
-static inline char *
-ink_string_copy(char *dest, char *src, int n)
-{
- char *s, *d;
-
- s = src;
- d = dest;
-
- while ((n > 1) && *s) {
- *d++ = *s++;
- --n;
- }
-
- if (n > 0)
- *d = '\0';
-
- return (dest);
-} /* End ink_string_copy */
-
// inline int ptr_len_cmp(const char* p1, int l1, const char* p2, int l2)
//
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/17ec6c20/proxy/logging/LogBuffer.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogBuffer.cc b/proxy/logging/LogBuffer.cc
index ed75174..18a569e 100644
--- a/proxy/logging/LogBuffer.cc
+++ b/proxy/logging/LogBuffer.cc
@@ -646,8 +646,7 @@ LogBuffer::to_ascii(LogEntryHeader * entry, LogFormatType type,
// text log entries are just strings, so simply move it into the
// format buffer.
//
- ink_string_copy(write_to, read_from, buf_len);
- return (int)::strlen(write_to); // OPTIMIZE, should not need strlen
+ return ink_strlcpy(write_to, read_from, buf_len);
}
//
// We no longer make the distinction between custom vs pre-defined