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
int when the first operand is lower than the second one
- a positive
int when the first operand is greater than the second one
- zero as an
int when 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); }
In the subject of
libasm, it is said that theft_list_sortfunction 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 bycmpwill be used as follows:cmpcould be for instance ft_strcmp.»This last sentence makes us understand that the comparison function shall return:
intwhen the first operand is lower than the second oneintwhen the first operand is greater than the second oneintwhen the two operands are equalThat being said, the current comparison function in the
ft_list_sorttests is: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: