trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject svn commit: r1171359 - in /trafficserver/traffic/trunk/lib/ts: ink_string.cc ink_string.h
Date Fri, 16 Sep 2011 02:10:12 GMT
Author: igalic
Date: Fri Sep 16 02:10:12 2011
New Revision: 1171359

URL: http://svn.apache.org/viewvc?rev=1171359&view=rev
Log:
TS-953: Add ink_strncat for symmetry, n.b.: This will be removed later when it proves useless.

Modified:
    trafficserver/traffic/trunk/lib/ts/ink_string.cc
    trafficserver/traffic/trunk/lib/ts/ink_string.h

Modified: trafficserver/traffic/trunk/lib/ts/ink_string.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_string.cc?rev=1171359&r1=1171358&r2=1171359&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_string.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_string.cc Fri Sep 16 02:10:12 2011
@@ -54,6 +54,29 @@ ink_strncpy(char *dest, const char *src,
   return (dest);
 }                               /* End ink_strncpy */
 
+/*---------------------------------------------------------------------------*
+
+  char *ink_strncat(char *dest, char *src, int n)
+
+  This routine is a safer version of strncat which always NUL terminates
+  the destination string.  Note that this routine has the SAME semantics
+  as strncat, such as concatinating exactly n bytes, padding dest with NULs
+  is necessary.  Use ink_string_copy for a non-padding version.
+
+ *---------------------------------------------------------------------------*/
+
+char *
+ink_strncat(char *dest, const char *src, int n)
+{
+  if (likely(src && dest)) {
+    if (n > 1)
+      strncat(dest, src, (n - 1));
+    if (n > 0)
+      dest[n - 1] = '\0';
+  }
+
+  return (dest);
+}                               /* End ink_strncat */
 
 /*---------------------------------------------------------------------------*
 

Modified: trafficserver/traffic/trunk/lib/ts/ink_string.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_string.h?rev=1171359&r1=1171358&r2=1171359&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_string.h (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_string.h Fri Sep 16 02:10:12 2011
@@ -50,6 +50,7 @@
 /* these are supposed to be fast */
 
 inkcoreapi char *ink_strncpy(char *dest, const char *src, int n);
+inkcoreapi char *ink_strncat(char *dest, const char *src, int n);
 inkcoreapi char *ink_string_concatenate_strings(char *dest, ...);
 inkcoreapi char *ink_string_concatenate_strings_n(char *dest, int n, ...);
 inkcoreapi char *ink_string_append(char *dest, char *src, int n);



Mime
View raw message