On Wed, Mar 24, 2010 at 3:32 PM, Dan McGee <[email protected]> wrote: > > I'd rather have it not touch the original list. Even if it does modify > the list, freeing items from the list could be disastrous in the case > of packages or something, so that is a no-no. I could see it being a > more useful function if it too took a comparison function and used > that to decide whether two things were equal (passing it along to > alpm_list_find). > > One option would be to make the signature look like this: > alpm_list_t *alpm_list_remove_dupes(const alpm_list_t *list, > alpm_list_fn_cmp fn, alpm_list_t **removed); > > This would, I think, allow for a variety of use cases. The function > would work similar to what it does now, but use the comparator to > determine whether things are equal and should be purged. In addition, > by returning the removed items from the list, it would allow the > calling site to determine what to do- e.g. free just the resulting > removed list or free the list + items inside. >
So we would need to call free_list on the original list passed as argument, and free_list + free_list_inner on both the result returned by alpm_list_remove_dupes and removed ?
