shared: Use hashmap free functions and don't manually iterate

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>