-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
In the subject of libasm, it is said that the ft_list_sort function must be «like the one in the piscine», so it refers to the subject of the C12, in which it is said that the «Function pointed by cmp will be used as follows:
(*cmp)(list_ptr->data, list_other_ptr->data);cmp could be for instance ft_strcmp.»
This last sentence makes us understand that the comparison function shall return:
- a negative
intwhen the first operand is lower than the second one - a positive
intwhen the first operand is greater than the second one - zero as an
intwhen the two operands are equal
That being said, the current comparison function in the ft_list_sort tests is:
int lower(void *d1, void *d2) { return ((long long)d1 > (long long)d2); }Which returns either 1 (a positive int) when the first operand is lower than the second one, or 0 otherwise. Therefore, it doesn't meet the requirement of the subject, and should be replaced by something like:
int lower(void *d0, void *d1) { return (int)((__UINTPTR_TYPE__)d0 - (__UINTPTR_TYPE__)d1); }Metadata
Metadata
Assignees
Labels
No labels