IVGCVSW-4542 Refactor TimelineDecoder parsing of TimelinePackets

 * Added test to add multiple SwTraceMessages to the buffer
 * Updated TimelineCaptureCommandHandler to iterate until there
   are no more read functions in the packet
 * Further commenting

Change-Id: I41d5acf4f7288ce5a51ffd10a5eea335ac3026ec
Signed-off-by: Keith Davis <keith.davis@arm.com>
diff --git a/src/profiling/ProfilingUtils.hpp b/src/profiling/ProfilingUtils.hpp
index 2604361..37ab88c 100644
--- a/src/profiling/ProfilingUtils.hpp
+++ b/src/profiling/ProfilingUtils.hpp
@@ -108,7 +108,10 @@
     // Prepare the output buffer
     size_t s_size        = s.size() + 1;    // The size of the string (in chars) plus the null-terminator
     size_t uint32_t_size = sizeof(uint32_t);
-    size_t outBufferSize = 1 + s_size / uint32_t_size + (s_size % uint32_t_size != 0 ? 1 : 0);
+    // Output buffer size = StringLength (32 bit) + amount of complete 32bit words that fit into the string
+    //                      + an additional 32bit word if there are remaining chars to complete the string
+    //                      (The rest of the 32bit word is then filled with the NULL terminator)
+    size_t outBufferSize = 1 + (s_size / uint32_t_size) + (s_size % uint32_t_size != 0 ? 1 : 0);
     outputBuffer.resize(outBufferSize, '\0');
 
     // Write the SWTrace string to the output buffer