lib/cmap: Add more hmap-like functionality.