Properly cleaning up the display tabs

This patch properly cleans up the display tabs so that none of the tab
data is being leaked between refresh changes

Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>

v2: rebased atop 41c54e8; there's a bug here

Signed-off-by: Joe Konno <joe.konno@intel.com>
Removing a documented memory leak

A non-elegant solution to it, but it works well enough to remove the
documented memory leak.  Proves to provide a much larger impact on
memory constrained systems.

v2: rebased atop 41c54e8

Signed-off-by: Joe Konno <joe.konno@intel.com>
Remove another memory leak

Pointer gets over written without ever being properly cleaned up.  This
should solve that problem.

v2: rebased atop 41c54e8, do not delete window in clear_tunables() to
prevent double-free in close_display().

Signed-off-by: Joe Konno <joe.konno@intel.com>
Mark pretty_print_init as initialized

There is a check for it, but it's never actually set.  Now it's set.

v2: rebased atop 41c54e8

Signed-off-by: Joe Konno <joe.konno@intel.com>
Limit sprintf to buffer size length.

Not completely needed, but good practice.  Limiting sprintf to the
length of the buffer size.  This patch not completely necessary as it's
unlikely to be an issue here.

v2: rebase atop 41c54e8; adaptated to newer context

Signed-off-by: Joe Konno <joe.konno@intel.com>
Stop buffer overflow

On some builds of Android, we are seeing entries that overrun this
buffer causing some ill-advised effects.  Limiting the buffer copies to
the size of the allocated buffer solves this issue.

v2: rebased atop 41c54e8

Signed-off-by: Joe Konno <joe.konno@intel.com>
Clean up potential buffer issues

While no issues have been seen in this section of code yet, it's likely
the same issues that show on the active display will also show on the
report process.

v2: rebased atop 41c54e8

Signed-off-by: Joe Konno <joe.konno@intel.com>
Adding a clean_shutdown function

Function is designed to be a on stop place to clean up the entire
application at shutdown time.

v2: rebased atop 41c54e8

Signed-off-by: Joe Konno <joe.konno@intel.com>