static sqlite3* db_handle = NULL;
char* path = NULL;
int g_fpid = -1;
+int g_ref_cnt = 0;
static int __vc_db_transaction(const char* transaction)
{
{
SLOG(LOG_INFO, vc_db_tag(), "DB initialization");
+ if (0 < g_ref_cnt) {
+ g_ref_cnt++;
+ return VC_DB_ERROR_NONE;
+ }
+
path = (char*)calloc(256, sizeof(char));
if (NULL == path) {
SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to allocate memory");
SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_exec returned %d: %s", ret, err_msg);
}
}
-
+ g_ref_cnt++;
return VC_DB_ERROR_NONE;
}
int vc_db_finalize(void)
{
+ if (0 >= g_ref_cnt) return VC_DB_ERROR_INVALID_STATE;
+ if (0 != --g_ref_cnt)
+ return VC_DB_ERROR_NONE;
+
if (NULL != path) {
free(path);
path = NULL;