Morten Welinder <mwelinder@gmail.com> writes: > The code looks wrong. It assumes that pointers are no larger than ints. > If pointers are larger than ints, the code does not necessarily compute > a consistent ordering and qsort is allowed to do whatever it wants. > > Morten > > > > static int compare_object_pointers(const void *a, const void *b) > { > const struct object * const *pa = a; > const struct object * const *pb = b; > return *pa - *pb; > } Are you suggesting it to be done like this? --- git diff diff --git a/object.c b/object.c index 427e14c..dac5c92 100644 --- a/object.c +++ b/object.c @@ -82,7 +82,12 @@ static int compare_object_pointers(const { const struct object * const *pa = a; const struct object * const *pb = b; - return *pa - *pb; + if (*pa == *pb) + return 0; + else if (*pa < *pb) + return -1; + else + return 1; } void set_object_refs(struct object *obj, struct object_refs *refs) - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlReceived on Wed Dec 07 08:42:23 2005
This archive was generated by hypermail 2.1.8 : 2005-12-07 08:42:29 EST