Reuse the buffer that holds data to be flushed to file

We use a buffer to generate the trace data in the right format to be
flushed to the file. In streaming mode, we used to allocate and delete
on each flush. Since we need it often, just have one buffer and release
it when the tracing has finished. In non-streaming mode, we used a
global buffer already. We reuse the same buffer but only allocate a
fixed size buffer instead of the user specified size. In streaming mode
the buffer size provided by the user isn't used.

Test: test.py -t 2246
Bug: 259258187
Change-Id: I0710a24ba3ba3fe2534bde0369975cc46ab9c7f4
2 files changed