libmemhack: rework the config memory management

The idea not to use the heap is too inflexible. So allocate the
whole config on the heap. Allocate space for the first object
address and double the space every time it doesn't fit anymore.
Maintain an insertion index for optimization. All this needs to be
protected. So introduce the use of a pthread mutex.
This simplifies and stabalizes the whole thing and memory gets
aligned to work on ARM as well.