[Lldb-commits] [lldb] r256223 - No need for a custom function here; just use what C provides

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 21 16:47:37 PST 2015


Author: enrico
Date: Mon Dec 21 18:47:36 2015
New Revision: 256223

URL: http://llvm.org/viewvc/llvm-project?rev=256223&view=rev
Log:
No need for a custom function here; just use what C provides

Modified:
    lldb/trunk/source/Core/ValueObject.cpp

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=256223&r1=256222&r2=256223&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Dec 21 18:47:36 2015
@@ -1178,31 +1178,6 @@ ValueObject::SetData (DataExtractor &dat
     return true;
 }
 
-// will compute strlen(str), but without consuming more than
-// maxlen bytes out of str (this serves the purpose of reading
-// chunks of a string without having to worry about
-// missing NULL terminators in the chunk)
-// of course, if strlen(str) > maxlen, the function will return
-// maxlen_value (which should be != maxlen, because that allows you
-// to know whether strlen(str) == maxlen or strlen(str) > maxlen)
-static uint32_t
-strlen_or_inf (const char* str,
-               uint32_t maxlen,
-               uint32_t maxlen_value)
-{
-    uint32_t len = 0;
-    if (str)
-    {
-        while(*str)
-        {
-            len++;str++;
-            if (len >= maxlen)
-                return maxlen_value;
-        }
-    }
-    return len;
-}
-
 static bool
 CopyStringDataToBufferSP(const StreamString& source,
                          lldb::DataBufferSP& destination)
@@ -1310,10 +1285,7 @@ ValueObject::ReadPointedString (lldb::Da
             {
                 total_bytes_read += bytes_read;
                 const char *cstr = data.PeekCStr(0);
-                size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1);
-                if (len > k_max_buf_size)
-                    len = k_max_buf_size;
-                
+                size_t len = strnlen (cstr, k_max_buf_size);
                 if (cstr_len_displayed < 0)
                     cstr_len_displayed = len;
                 




More information about the lldb-commits mailing list