dict.c: rewrite dict_clean_keys() for the new buffer interface