Re: Promoting unsigned long int to long int
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 30 Jun 2008 15:47:29 GMT
pereges <Broli00@xxxxxxxxx> wrote:
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)
Not exactly;-) I they're the same there's nothing to sort since
your array only has a single element, so I meant
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);
}
}Regards, Jens
else
return;
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: Promoting unsigned long int to long int
- From: pereges
- 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
- Re: Promoting unsigned long int to long int
- From: pereges
- Promoting unsigned long int to long int
- Prev by Date: Re: how to release memory?
- Next by Date: Re: Promoting unsigned long int to long int
- Previous by thread: Re: Promoting unsigned long int to long int
- Next by thread: Re: Promoting unsigned long int to long int
- Index(es):
Relevant Pages
|