The pointer to the specified map object can not be freed before calling am_map_destroy(). This includes erroneously calling the system free(void *) function.