Fix rosalloc issues with valgrind.
The issue was that the MemoryToolMallocSpace constructor was
explicitly undefining the tail of the mem map, and when RosAlloc
expanded the space beyond the initial size, it gets errors from using
the zero but undefined (due to the above undefining) memory
content. RosAlloc zeroes memory on free (as opposed to zeroes on
allocation) and relied on the zero-initialized (hence defined in terms
of valgrind) mem map at the initialization time.
Change RosAlloc so that it does explicitly zeroes the entire mem map at
the initialization time and it does not rely on the zero-initialized of
the mem map.
Also, avoid explicitly changing the valgrind state in the
MemoryToolMallocSpace constructor, which happens after the allocator is
initialized because that may interfere with the allocator internal
initialization.
Bug: 27156726
Bug: 9986565
Change-Id: I3b36d2d987c25ce9ff5213278109c425f480b0d9
3 files changed