freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] Use of qsort


From: Antoine Leca
Subject: Re: [Devel] Use of qsort
Date: Tue, 26 Jun 2001 19:45:09 +0200

Tom Kacvinsky wrote:
> 
> >
> > Also, a thing worth checking is whether any other part of our libraries, 
> > being
> > 1.x or 2.x, use any callback back to a standard library (qsort is just an 
> > example,
> > although it is probably the one which is the most probable).
> >
> 
> Where can one find a list of standard functions that use callbacks?

The C standard is a starter!

There (in C99), there are only 4 of them (and they existed in ANSI C89)
  7.14 <signal.h>   signal
  7.20 <stdlib.h>   atexit
                    bsearch
                    qsort

Then, we have the specials used in the ad hoc "graphics drivers", 'cause
GUI environments tend to use a lot callbacks, but I believe this has already
been tampered with with appropriate measures, since if not probably nothing
will ever work...


> Another thing one could do is make sure that all such
> functions (qsort, et. al.) are defined by FreeType, instead of using the
> standard library implementation.

What do you mean by "define"?

Should we provide our own implementation? (doable, but it is a lack of
resources and may discard optimizations done by the writers of the standard
libraries, not really a good thing IMHO)

Or do you really mean "declare", that is instead of #including <stdlib.h>,
just write the prototype
  void qsort(void *, size_t, size_t, int(*)(const void*, const void*));

This would turn into a Bad Idea(tm). Because then the compiler will force
qsort to be called by our code under the current convention (here, __fastcall),
and not the "correct" one that is expected by the implementation, which
BTW depends on a lot of factor (such as linked against a dynamic library,
use of memory models and all those nasty points that in effect require to
use the standard headers every time it is possible.


Antoine



reply via email to

[Prev in Thread] Current Thread [Next in Thread]