From 9745bbeb5bf5b8fc4b944c2400cf0ec295c2e0e0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 24 Oct 2014 09:39:28 +0000 Subject: double memory allocation removed git-svn-id: http://svn.miranda-ng.org/main/trunk@10859 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/db.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/mir_core/db.cpp') diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp index 9fc57870ad..079225682a 100644 --- a/src/mir_core/db.cpp +++ b/src/mir_core/db.cpp @@ -99,24 +99,20 @@ MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, const char *szModule, const ch MIR_CORE_DLL(char*) db_get_sa(MCONTACT hContact, const char *szModule, const char *szSetting) { - char *str = NULL; - DBVARIANT dbv = {0}; - db_get_s(hContact, szModule, szSetting, &dbv, DBVT_ASCIIZ); - if (dbv.type == DBVT_ASCIIZ) - str = mir_strdup(dbv.pszVal); - db_free(&dbv); - return str; + if (currDb == NULL) + return NULL; + + DBVARIANT dbv = { DBVT_ASCIIZ }; + return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.pszVal; } MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, const char *szModule, const char *szSetting) { - wchar_t *str = NULL; - DBVARIANT dbv={0}; - db_get_s(hContact, szModule, szSetting, &dbv, DBVT_WCHAR); - if (dbv.type == DBVT_WCHAR) - str = mir_wstrdup(dbv.pwszVal); - db_free(&dbv); - return str; + if (currDb == NULL) + return NULL; + + DBVARIANT dbv = { DBVT_WCHAR }; + return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.pwszVal; } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3