prune_refs(): also free the linked list