[LiSA-Devel] Comments on 4069be7

Radu Rendec radu.rendec at mindbit.ro
Wed Mar 6 23:15:04 EET 2013


On Wed, 2013-03-06 at 20:29 +0200, Andreea-Cristina Hodea wrote:
> On Wed, Mar 6, 2013 at 11:04 AM, Radu Rendec <radu.rendec at mindbit.ro> wrote:
> > Since you're not doing anything to the arguments (except for casting)
> > and to the return value, I guess you can do something like this:
> >
> > typedef int(*qsort_compare)(const void *, const void *);
> >
> > And then cast the strcmp symbol to this type before passing it to
> > qsort() - something like this:
> >
> > qsort( ... , (qsort_compare)strcmp)
> >
> I have tried this way on a simple example with array of strings and
> the array is not sorted properly at the end.

This approach could have worked with your initial implementation, where
the array contained the actual strings, not pointers to the strings. If
this is what you tried, then I'm kindly asking you to share your simple
example with me because I'm getting curious :)

For the new implementation (array of pointers to strings) I'm pretty
sure the only solution is a wrapper function, which is exactly what you
did.

> The updated sorting is already pushed. The argument with small stack
> was enough and I went with malloc instead.

Thanks for the patch! I took a quick look and it seems to be fine.

Radu




More information about the LiSA-Devel mailing list