* Just process lms_db_*_start() once.
* Check if _references would drop below 0 and log.
sqlite3_stmt *get_artist;
sqlite3_stmt *get_album;
sqlite3_stmt *get_genre;
- int _references;
+ unsigned int _references;
+ unsigned int _is_started:1;
};
static lms_db_audio_t *_singleton = NULL;
{
if (!lda)
return -1;
+ if (lda->_is_started)
+ return 0;
lda->insert_audio = lms_db_compile_stmt(lda->db,
"INSERT OR REPLACE INTO audios "
if (!lda->get_genre)
return -8;
+ lda->_is_started = 1;
return 0;
}
{
if (!lda)
return -1;
+ if (lda->_references == 0) {
+ fprintf(stderr, "ERROR: over-called lms_db_audio_free(%p)\n", lda);
+ return -1;
+ }
lda->_references--;
if (lda->_references > 0)
struct lms_db_image {
sqlite3 *db;
sqlite3_stmt *insert;
- int _references;
+ unsigned int _references;
+ unsigned int _is_started:1;
};
static lms_db_image_t *_singleton = NULL;
{
if (!ldi)
return -1;
+ if (ldi->_is_started)
+ return 0;
ldi->insert = lms_db_compile_stmt(ldi->db,
"INSERT OR REPLACE INTO images ("
if (!ldi->insert)
return -2;
+ ldi->_is_started = 1;
return 0;
}
{
if (!ldi)
return -1;
+ if (ldi->_references == 0) {
+ fprintf(stderr, "ERROR: over-called lms_db_image_free(%p)\n", ldi);
+ return -1;
+ }
ldi->_references--;
if (ldi->_references > 0)