Allocate histogram with palloc to avoid memleak
Allocate histogram with palloc to avoid memleak

The histogram structure was allocated statically via malloc(), but it
had no data retention between calls as it was purely a microoptimization
to avoid the cost of repeated allocations. This lead to the allocated
memory leaking as it's not cleaned up automatically. Fix by pallocing
the memory instead and take the cost of repeat allocation.

Also ensure to properly clean up allocated memory on failure cases.

Reviewed-by: Heikki Linnakangas <9304c20251d03f4d84fc732cc8196e9ef6638e64@pivotal.io>

xinzweb/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,adam8157/gpdb,50wu/gpdb,jmcatamney/gpdb,lisakowen/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,xinzweb/gpdb,xinzweb/gpdb,greenplum-db/gpdb,adam8157/gpdb,50wu/gpdb,xinzweb/gpdb,adam8157/gpdb,lisakowen/gpdb,xinzweb/gpdb,greenplum-db/gpdb,xinzweb/gpdb,50wu/gpdb,lisakowen/gpdb,50wu/gpdb,ashwinstar/gpdb,xinzweb/gpdb,50wu/gpdb,ashwinstar/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,lisakowen/gpdb,adam8157/gpdb,lisakowen/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,50wu/gpdb,50wu/gpdb,adam8157/gpdb,50wu/gpdb,lisakowen/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,adam8157/gpdb,jmcatamney/gpdb,adam8157/gpdb,adam8157/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,lisakowen/gpdb