-static void dest_tsd(void *arg)
-{
- if (arg != NULL) {
- check_handles(arg);
- free(arg);
- }
-}
-
-/*
- * Ensure that we have a key for thread-specific data. We don't
- * put anything in here that Citadel cares about; this is just database
- * related stuff like cursors and transactions.
- *
- * This should be called immediately after startup by any thread which wants
- * to use database calls, except for whatever thread calls open_databases.
- */
-void cdb_allocate_tsd(void)
-{
- struct cdbtsd *tsd;
-
- if (pthread_getspecific(tsdkey) != NULL)
- return;
-
- tsd = malloc(sizeof(struct cdbtsd));
-
- tsd->tid = NULL;
-
- memset(tsd->cursors, 0, sizeof tsd->cursors);
- pthread_setspecific(tsdkey, tsd);
-}
-
-void cdb_free_tsd(void)
-{
- dest_tsd(pthread_getspecific(tsdkey));
- pthread_setspecific(tsdkey, NULL);
-}
-