[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 628306c: Minor cleanups of sqlite3 code on MS-Windows
From: |
Eli Zaretskii |
Subject: |
master 628306c: Minor cleanups of sqlite3 code on MS-Windows |
Date: |
Sat, 11 Dec 2021 04:27:16 -0500 (EST) |
branch: master
commit 628306c299923551cdc8cf09c874744ae7b74216
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Minor cleanups of sqlite3 code on MS-Windows
* src/sqlite.c (sqlite_loaded_p): Function deleted: not used
anymore.
(init_sqlite_functions) [WINDOWSNT]: Use a static 'bool' variable
to indicate if sqlite3 DLL was successfully loaded.
(Fsqlite_available_p) [WINDOWSNT]: Just call
'init_sqlite_functions' if Vlibrary_cache doesn't mention
'sqlite3'.
---
src/sqlite.c | 48 ++++++++++++++++--------------------------------
1 file changed, 16 insertions(+), 32 deletions(-)
diff --git a/src/sqlite.c b/src/sqlite.c
index aea7940..47829cb 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -151,43 +151,32 @@ load_dll_functions (HMODULE library)
LOAD_DLL_FN (library, sqlite3_prepare_v2);
return true;
}
-
-static bool
-sqlite_loaded_p (void)
-{
- Lisp_Object found = Fassq (Qsqlite3, Vlibrary_cache);
-
- return CONSP (found) && EQ (XCDR (found), Qt);
-}
#endif /* WINDOWSNT */
static bool
init_sqlite_functions (void)
{
#ifdef WINDOWSNT
- if (sqlite_loaded_p ())
- return true;
- else
+ static bool sqlite3_initialized;
+
+ if (!sqlite3_initialized)
{
- HMODULE library;
+ HMODULE library = w32_delayed_load (Qsqlite3);
- if (!(library = w32_delayed_load (Qsqlite3)))
+ if (!library)
+ message1 ("sqlite3 library was not found");
+ else if (load_dll_functions (library))
{
- message1 ("sqlite3 library not found");
- return false;
+ sqlite3_initialized = true;
+ Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qt), Vlibrary_cache);
+ }
+ else
+ {
+ message1 ("sqlite3 library was found, but could not be loaded
successfully");
+ Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qnil), Vlibrary_cache);
}
-
- if (! load_dll_functions (library))
- goto bad_library;
-
- Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qt), Vlibrary_cache);
- return true;
}
-
- bad_library:
- Vlibrary_cache = Fcons (Fcons (Qsqlite3, Qnil), Vlibrary_cache);
-
- return false;
+ return sqlite3_initialized;
#else /* !WINDOWSNT */
return true;
#endif /* !WINDOWSNT */
@@ -674,12 +663,7 @@ DEFUN ("sqlite-available-p", Fsqlite_available_p,
Ssqlite_available_p, 0, 0, 0,
if (CONSP (found))
return XCDR (found);
else
- {
- Lisp_Object status;
- status = init_sqlite_functions () ? Qt : Qnil;
- Vlibrary_cache = Fcons (Fcons (Qsqlite3, status), Vlibrary_cache);
- return status;
- }
+ return init_sqlite_functions () ? Qt : Qnil;
# else
return Qt;
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 628306c: Minor cleanups of sqlite3 code on MS-Windows,
Eli Zaretskii <=