Re: Promoting unsigned long int to long int
- From: pereges <Broli00@xxxxxxxxx>
- Date: Mon, 30 Jun 2008 07:51:18 -0700 (PDT)
On Jun 30, 5:07 pm, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:
Using unsigned long should be completely ok.
Ok.
And j gets set to ULONG_MAX (unsigned integers "wrap around").
That will keep you in this loop for a loooong time and you will
try to access elements of your array that don't exist, rather
likely resulting in a crash.
Yeah, I notice that too.
The simplest solution is to just bail out of the function if
left is equal to right - there's nothing to sort in that case.
You mean :
void quicksort (void quicksort(vector **parent_vpa, ulong left, ulong
right, uchar
axis)
{
ulong i, j;
if (left == right)
{
i = left;
j = right;
while (i <= j)
{
...
}
if (left < j)
{
quicksort(parent_vpa, left, j, axis);
}
if (i < right)
{
quicksort(parent_vpa, i, right, axis);
}
}
else
return;
.
- Follow-Ups:
- Re: Promoting unsigned long int to long int
- From: Jens Thoms Toerring
- Re: Promoting unsigned long int to long int
- References:
- Promoting unsigned long int to long int
- From: pereges
- Re: Promoting unsigned long int to long int
- From: Jens Thoms Toerring
- Promoting unsigned long int to long int
- Prev by Date: Re: Pedants
- Next by Date: Re: program won't work
- Previous by thread: Re: Promoting unsigned long int to long int
- Next by thread: Re: Promoting unsigned long int to long int
- Index(es):