J
jacob navia
Within the context of the container library, sorting needs a callback
with more than just the two elements to be compared. The standard
qsort function has a callback that takes only two arguments.
This wasn't a big problem since I just adapted the code of lcc-win's
C library to receive one more argument and the problem was gone.
I wonder now, if my problem could be maybe more widespread than I
think. I named the new function: "qsortEx" with the prototype:
void qsortEx(void *base,
size_t num,
size_t width,
int(*cmp) (const void *elem1,
const void *elem2,
void *ExtraArgs),
void *ExtraArgs);
The ExtraArgs aren't "const" since precisely the callbacks could modify
it during the sort.
All this avoids global variables, that are the only solution here.
Has anyone of you seen a function like this?
Is there a C library that provides this?
Thanks in advance.
jacob
with more than just the two elements to be compared. The standard
qsort function has a callback that takes only two arguments.
This wasn't a big problem since I just adapted the code of lcc-win's
C library to receive one more argument and the problem was gone.
I wonder now, if my problem could be maybe more widespread than I
think. I named the new function: "qsortEx" with the prototype:
void qsortEx(void *base,
size_t num,
size_t width,
int(*cmp) (const void *elem1,
const void *elem2,
void *ExtraArgs),
void *ExtraArgs);
The ExtraArgs aren't "const" since precisely the callbacks could modify
it during the sort.
All this avoids global variables, that are the only solution here.
Has anyone of you seen a function like this?
Is there a C library that provides this?
Thanks in advance.
jacob