On 10/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> On win32, we have to initialize mutexes at run-time, but this
> can be done within a contrived mutex that we build off of
> a static integer using InterlockedIncrement().  And mutex
> initialization apparently never fails on win32, so we do not
> have to worry with reporting errors that occur during
> mutex initialization.

That isn't actually true, but handling that particular, rare
out-of-memory error condition that can occur with CriticalSections is
so amazingly inconvenient that most people don't even bother trying :)

> But there are other operating systems using SQLite that do
> not work this way.  They need a way to initialize mutexes
> (and possibly other objects such as malloc) prior to running
> any SQLite interface.  And the initialization needs to be able
> to fail and return an error code.
>
> To accomodate this need, we are considering an incompatible
> API change to SQLite.  We are thinking of requiring that an
> application invoke:
>
>     int sqlite3_initialize(...);
>
> prior to using any other SQLite interface.  (The parameters to
> sqlite3_initialize() are not yet designed.)  It will be an error
> to use any other SQLite interface without first invoking
> sqlite3_initialize() exactly one.  It is also an error to
> invoke sqlite3_initialize() more than once.

Some thoughts:

* Definitely a major version change.

* In order to correctly handle dynamic library scenarios, there needs
to be a pair of initialize/finalize functions, and they need to be
counted.  The first intitialize() does the work, the rest simply
increment a counter.  The last finalize() does the work, the rest
simply decrement.

* For future flexibility, I'd suggest making one of the arguments to
initialize() be a pointer to a struct.  The first member of the struct
should be a version indicator, like the VFS interface.

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to