block building with malloc and logging

Signed-off-by: Sergei Ianovich <ynvich@gmail.com>