I asked, cause I simply changed the return 2 and return 1 to 1 and -1 and
it's working fine. So I don't see why I need to allocate an array for it to
work with. ESP an allocated array that isn't freed when it's finished so
with that I've allocated the needed memory for the helps twice havn't i?


----- Original Message ----- 
From: "Joseph Dale" <[EMAIL PROTECTED]>
To: "Dale Kingston" <[EMAIL PROTECTED]>
Sent: Wednesday, January 28, 2004 11:05 AM
Subject: Re: Qsort


> You need to allocate the array you are placing the results into.
> regards
>
>
> Dale Kingston writes:
>
> > Why do I need to allocate anything? It's already allocated all the
memory
> > needed for the helpfiles already. I'm just sorting what it's already
> > allocated...
> >
> > ----- Original Message ----- 
> > From: "Richard Lindsey" <[EMAIL PROTECTED]>
> > To: "Chad Simmons" <[EMAIL PROTECTED]>; <[email protected]>
> > Sent: Wednesday, January 28, 2004 10:51 AM
> > Subject: RE: Qsort
> >
> >
> > One quick edit on that last post... I think that...
> >
> >    /* Count the members in the linked list */
> >    for (nmemb = 0, help = help_first; help != NULL; help =
> > help->next,nmemb++);
> >
> >    return if(!nmemb);
> >
> >    /* Create an array to store them */
> >    help_array= alloc_mem(sizeof(help) * i);
> >    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this line
> >
> > should actually read:
> >
> >    help_array= alloc_mem(sizeof(help) * nmemb);
> >
> > so that it allocates the sizeof help times the number of elements it
> > counted in that first for loop...
> >
> > Richard Lindsey
> >
> >
> > -- 
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom
> >
> >
> > -- 
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom
>


Reply via email to