]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge revision 14309 from BUF_REMOVAL branch to trunk.
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 28 Oct 2014 20:52:07 +0000 (20:52 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 28 Oct 2014 20:52:07 +0000 (20:52 +0000)
Eliminates a fixed size buffer in helgrind. Instead of building up a
string in a buffer and then writing the string to stdout can as well
write to stdout directly.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14672

helgrind/libhb_core.c

index 3659aadfa8be72a8699c296e8076761efe6288a9..1668df86116f136b2d1da7978dfb80b9bf0a686f 100644 (file)
@@ -1913,8 +1913,8 @@ static UInt VTS__cmpLEQ ( VTS* a, VTS* b );
    Returns -1, 0 or 1. */
 static Word VTS__cmp_structural ( VTS* a, VTS* b );
 
-/* Debugging only.  Display the given VTS in the buffer. */
-static void VTS__show ( HChar* buf, Int nBuf, VTS* vts );
+/* Debugging only.  Display the given VTS. */
+static void VTS__show ( const VTS* vts );
 
 /* Debugging only.  Return vts[index], so to speak. */
 static ULong VTS__indexAt_SLOW ( VTS* vts, Thr* idx );
@@ -2378,35 +2378,20 @@ Word VTS__cmp_structural ( VTS* a, VTS* b )
 }
 
 
-/* Debugging only.  Display the given VTS in the buffer.
+/* Debugging only.  Display the given VTS.
 */
-void VTS__show ( HChar* buf, Int nBuf, VTS* vts )
+static void VTS__show ( const VTS* vts )
 {
-   ScalarTS* st;
-   HChar     unit[64];
    Word      i, n;
-   Int       avail = nBuf;
    tl_assert(vts && vts->ts);
-   tl_assert(nBuf > 16);
-   buf[0] = '[';
-   buf[1] = 0;
+
+   VG_(printf)("[");
    n =  vts->usedTS;
    for (i = 0; i < n; i++) {
-      tl_assert(avail >= 40);
-      st = &vts->ts[i];
-      VG_(memset)(unit, 0, sizeof(unit));
-      VG_(sprintf)(unit, i < n-1 ? "%u:%llu " : "%u:%llu",
-                         st->thrid, (ULong)st->tym);
-      if (avail < VG_(strlen)(unit) + 40/*let's say*/) {
-         VG_(strcat)(buf, " ...]");
-         buf[nBuf-1] = 0;
-         return;
-      }
-      VG_(strcat)(buf, unit);
-      avail -= VG_(strlen)(unit);
+      const ScalarTS *st = &vts->ts[i];
+      VG_(printf)(i < n-1 ? "%u:%llu " : "%u:%llu", st->thrid, (ULong)st->tym);
    }
-   VG_(strcat)(buf, "]");
-   buf[nBuf-1] = 0;
+   VG_(printf)("]");
 }
 
 
@@ -3202,11 +3187,8 @@ static VTS* VtsID__to_VTS ( VtsID vi ) {
 }
 
 static void VtsID__pp ( VtsID vi ) {
-   HChar buf[100];
    VTS* vts = VtsID__to_VTS(vi);
-   VTS__show( buf, sizeof(buf)-1, vts );
-   buf[sizeof(buf)-1] = 0;
-   VG_(printf)("%s", buf);
+   VTS__show( vts );
 }
 
 /* compute partial ordering relation of vi1 and vi2. */