diff options
author | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:03:31 +0100 |
---|---|---|
committer | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:07:33 +0100 |
commit | a7c24ca48995cf2bf436156302f96b91bf135409 (patch) | |
tree | 953835509ff1b778833e78fd7b74b05e05e77c84 /src/mir_core | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'src/mir_core')
31 files changed, 478 insertions, 478 deletions
diff --git a/src/mir_core/src/CCtrlTreeView.cpp b/src/mir_core/src/CCtrlTreeView.cpp index 1144bd2864..24a80d35d7 100644 --- a/src/mir_core/src/CCtrlTreeView.cpp +++ b/src/mir_core/src/CCtrlTreeView.cpp @@ -62,7 +62,7 @@ HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter, return hItem; wchar_t name[128]; - TVINSERTSTRUCT tvis = { 0 }; + TVINSERTSTRUCT tvis = {}; tvis.itemex.mask = (UINT)-1; tvis.itemex.pszText = name; tvis.itemex.cchTextMax = _countof(name); @@ -319,7 +319,7 @@ void CCtrlTreeView::TranslateTree() while (hItem) { TranslateItem(hItem); - HTREEITEM hItemTmp = 0; + HTREEITEM hItemTmp = nullptr; if (hItemTmp = GetChild(hItem)) hItem = hItemTmp; else if (hItemTmp = GetNextSibling(hItem)) diff --git a/src/mir_core/src/CDbLink.cpp b/src/mir_core/src/CDbLink.cpp index cd276eccd7..a428d1e9e6 100644 --- a/src/mir_core/src/CDbLink.cpp +++ b/src/mir_core/src/CDbLink.cpp @@ -31,7 +31,7 @@ CDbLink::CDbLink(const char *szModule, const char *szSetting, BYTE type, DWORD i m_szModule = mir_strdup(szModule);
m_szSetting = mir_strdup(szSetting);
m_iDefault = iValue;
- m_szDefault = 0;
+ m_szDefault = nullptr;
dbv.type = DBVT_DELETED;
}
diff --git a/src/mir_core/src/binbuffer.cpp b/src/mir_core/src/binbuffer.cpp index a418a4326c..29cc6b636a 100644 --- a/src/mir_core/src/binbuffer.cpp +++ b/src/mir_core/src/binbuffer.cpp @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" MBinBuffer::MBinBuffer() : - m_buf(NULL), + m_buf(nullptr), m_len(0) { } @@ -30,7 +30,7 @@ MBinBuffer::~MBinBuffer() void MBinBuffer::append(void *pBuf, size_t bufLen) { - if (pBuf == NULL || bufLen == 0) + if (pBuf == nullptr || bufLen == 0) return; m_buf = (char*)mir_realloc(m_buf, bufLen + m_len); @@ -43,7 +43,7 @@ void MBinBuffer::append(void *pBuf, size_t bufLen) void MBinBuffer::appendBefore(void *pBuf, size_t bufLen) { - if (pBuf == NULL || bufLen == 0) + if (pBuf == nullptr || bufLen == 0) return; m_buf = (char*)mir_realloc(m_buf, bufLen + m_len); @@ -62,7 +62,7 @@ void MBinBuffer::remove(size_t sz) if (m_len == sz) { m_len = 0; - mir_free(m_buf); m_buf = NULL; + mir_free(m_buf); m_buf = nullptr; } else { memmove(m_buf, m_buf + sz, m_len - sz); diff --git a/src/mir_core/src/bitmaps.cpp b/src/mir_core/src/bitmaps.cpp index 6d0084628e..2269af1ee0 100644 --- a/src/mir_core/src/bitmaps.cpp +++ b/src/mir_core/src/bitmaps.cpp @@ -32,14 +32,14 @@ MIR_CORE_DLL(HBITMAP) Bitmap_Load(const wchar_t *ptszFileName) wcsncpy_s(szFilename, ptszFileName, _TRUNCATE);
if (!ServiceExists(MS_IMG_LOAD))
- return NULL;
+ return nullptr;
return (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)szFilename, IMGL_WCHAR);
}
MIR_CORE_DLL(void) Bitmap_GetFilter(wchar_t *dest, size_t destLen)
{
- if (dest == NULL)
+ if (dest == nullptr)
return;
mir_snwprintf(dest, destLen,
diff --git a/src/mir_core/src/cmdline.cpp b/src/mir_core/src/cmdline.cpp index 61570068ef..d03c5b36ef 100644 --- a/src/mir_core/src/cmdline.cpp +++ b/src/mir_core/src/cmdline.cpp @@ -60,7 +60,7 @@ MIR_CORE_DLL(void) CmdLine_Parse(LPTSTR ptszCmdLine) else continue; // skip a text that isn't an option
wchar_t *pOptionName = p+1;
- if ((p = wcspbrk(pOptionName, L" \t=:")) == NULL) { // no more text in string
+ if ((p = wcspbrk(pOptionName, L" \t=:")) == nullptr) { // no more text in string
arParams.insert(new CmdLineParam(pOptionName, L""));
break;
}
@@ -74,7 +74,7 @@ MIR_CORE_DLL(void) CmdLine_Parse(LPTSTR ptszCmdLine) // parameter with value
*p = 0;
arParams.insert(new CmdLineParam(pOptionName, ++p));
- if ((p = wcspbrk(p, L" \t")) == NULL) // no more text in string
+ if ((p = wcspbrk(p, L" \t")) == nullptr) // no more text in string
break;
p--; // the cycle will wipe this space automatically
@@ -83,7 +83,7 @@ MIR_CORE_DLL(void) CmdLine_Parse(LPTSTR ptszCmdLine) MIR_CORE_DLL(LPCTSTR) CmdLine_GetOption(const wchar_t* ptszParameter)
{
- CmdLineParam tmp(ptszParameter, 0);
+ CmdLineParam tmp(ptszParameter, nullptr);
int idx = arParams.getIndex(&tmp);
- return (idx == -1) ? NULL : arParams[idx].value;
+ return (idx == -1) ? nullptr : arParams[idx].value;
}
diff --git a/src/mir_core/src/colourpicker.cpp b/src/mir_core/src/colourpicker.cpp index a202c58630..d0041aa116 100644 --- a/src/mir_core/src/colourpicker.cpp +++ b/src/mir_core/src/colourpicker.cpp @@ -41,7 +41,7 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wPar case CPM_SETCOLOUR:
SetWindowLongPtr(hwnd, 0, lParam);
- InvalidateRect(hwnd, NULL, FALSE);
+ InvalidateRect(hwnd, nullptr, FALSE);
break;
case CPM_GETCOLOUR:
@@ -62,13 +62,13 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wPar if (ChooseColor(&cc)) {
SetWindowLongPtr(hwnd, 0, cc.rgbResult);
SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), CPN_COLOURCHANGED), (LPARAM)hwnd);
- InvalidateRect(hwnd, NULL, FALSE);
+ InvalidateRect(hwnd, nullptr, FALSE);
}
}
break;
case WM_ENABLE:
- InvalidateRect(hwnd, NULL, FALSE);
+ InvalidateRect(hwnd, nullptr, FALSE);
break;
case WM_NCPAINT:
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 9afe8177f1..ccd0cd1e9d 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-MIDatabase *currDb = NULL;
+MIDatabase *currDb = nullptr;
/////////////////////////////////////////////////////////////////////////////////////////
// database functions
@@ -70,7 +70,7 @@ MIR_CORE_DLL(int) db_delete_module(MCONTACT hContact, const char *szModuleName) MIR_CORE_DLL(MCONTACT) db_add_contact(void)
{
MCONTACT hNew = (currDb) ? currDb->AddContact() : 0;
- Netlib_Logf(NULL, "New contact created: %d", hNew);
+ Netlib_Logf(nullptr, "New contact created: %d", hNew);
return hNew;
}
@@ -80,7 +80,7 @@ MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact) if (wszPhoto != NULL)
DeleteFile(wszPhoto);
- Netlib_Logf(NULL, "Contact deleted: %d", hContact);
+ Netlib_Logf(nullptr, "Contact deleted: %d", hContact);
return (currDb) ? currDb->DeleteContact(hContact) : 0;
}
@@ -112,7 +112,7 @@ EXTERN_C MIR_CORE_DLL(int) db_enum_settings(MCONTACT hContact, DBSETTINGENUMPROC MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, const char *szModule, const char *szSetting, int errorValue)
{
- if (currDb != NULL) {
+ if (currDb != nullptr) {
DBVARIANT dbv;
if (!currDb->GetContactSetting(hContact, szModule, szSetting, &dbv))
{
@@ -129,7 +129,7 @@ MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, const char *szModule, const char * MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, const char *szModule, const char *szSetting, int errorValue)
{
- if (currDb != NULL) {
+ if (currDb != nullptr) {
DBVARIANT dbv;
if (!currDb->GetContactSetting(hContact, szModule, szSetting, &dbv)) {
switch(dbv.type) {
@@ -145,7 +145,7 @@ MIR_CORE_DLL(int) db_get_w(MCONTACT hContact, const char *szModule, const char * MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, const char *szModule, const char *szSetting, DWORD errorValue)
{
- if (currDb != NULL) {
+ if (currDb != nullptr) {
DBVARIANT dbv;
if (!currDb->GetContactSetting(hContact, szModule, szSetting, &dbv)) {
switch(dbv.type) {
@@ -162,7 +162,7 @@ MIR_CORE_DLL(DWORD) db_get_dw(MCONTACT hContact, const char *szModule, const cha MIR_CORE_DLL(INT_PTR) db_get(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
- if (currDb == NULL)
+ if (currDb == nullptr)
return 1;
return currDb->GetContactSetting(hContact, szModule, szSetting, dbv);
@@ -170,7 +170,7 @@ MIR_CORE_DLL(INT_PTR) db_get(MCONTACT hContact, const char *szModule, const char MIR_CORE_DLL(INT_PTR) db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType)
{
- if (currDb == NULL)
+ if (currDb == nullptr)
return 1;
dbv->type = (BYTE)nType;
@@ -179,20 +179,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)
{
- if (currDb == NULL)
- return NULL;
+ if (currDb == nullptr)
+ return nullptr;
DBVARIANT dbv = { DBVT_ASCIIZ };
- return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.pszVal;
+ return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? nullptr : dbv.pszVal;
}
MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, const char *szModule, const char *szSetting)
{
- if (currDb == NULL)
- return NULL;
+ if (currDb == nullptr)
+ return nullptr;
DBVARIANT dbv = { DBVT_WCHAR };
- return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.pwszVal;
+ return currDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? nullptr : dbv.pwszVal;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -200,7 +200,7 @@ MIR_CORE_DLL(wchar_t*) db_get_wsa(MCONTACT hContact, const char *szModule, const MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest)
{
- if (currDb == NULL)
+ if (currDb == nullptr)
return 1;
DBVARIANT dbv;
@@ -212,7 +212,7 @@ MIR_CORE_DLL(int) db_get_static(MCONTACT hContact, const char *szModule, const c MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, const char *szModule, const char *szSetting, char *pDest, int cbDest)
{
- if (currDb == NULL)
+ if (currDb == nullptr)
return 1;
DBVARIANT dbv;
@@ -224,7 +224,7 @@ MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, const char *szModule, con MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *pDest, int cbDest)
{
- if (currDb == NULL)
+ if (currDb == nullptr)
return 1;
DBVARIANT dbv;
@@ -239,7 +239,7 @@ MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, const char *szModule, const MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
@@ -250,7 +250,7 @@ MIR_CORE_DLL(INT_PTR) db_set(MCONTACT hContact, const char *szModule, const char MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, const char *szModule, const char *szSetting, BYTE val)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
@@ -262,7 +262,7 @@ MIR_CORE_DLL(INT_PTR) db_set_b(MCONTACT hContact, const char *szModule, const ch MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, const char *szModule, const char *szSetting, WORD val)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
@@ -274,7 +274,7 @@ MIR_CORE_DLL(INT_PTR) db_set_w(MCONTACT hContact, const char *szModule, const ch MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, const char *szModule, const char *szSetting, DWORD val)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
@@ -286,43 +286,43 @@ MIR_CORE_DLL(INT_PTR) db_set_dw(MCONTACT hContact, const char *szModule, const c MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_ASCIIZ;
- cws.value.pszVal = (char*)(val == NULL ? "" : val);
+ cws.value.pszVal = (char*)(val == nullptr ? "" : val);
return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, const char *szModule, const char *szSetting, const WCHAR *val)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_WCHAR;
- cws.value.pwszVal = (WCHAR*)(val == NULL ? L"" : val);
+ cws.value.pwszVal = (WCHAR*)(val == nullptr ? L"" : val);
return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_utf(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_UTF8;
- cws.value.pszVal = (char*)(val == NULL ? "" : val);
+ cws.value.pszVal = (char*)(val == nullptr ? "" : val);
return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, const char *szModule, const char *szSetting, void *val, unsigned len)
{
- if (currDb == NULL) return 1;
+ if (currDb == nullptr) return 1;
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
@@ -338,62 +338,62 @@ MIR_CORE_DLL(INT_PTR) db_set_blob(MCONTACT hContact, const char *szModule, const MIR_CORE_DLL(MEVENT) db_event_add(MCONTACT hContact, DBEVENTINFO *dbei)
{
- return (currDb == NULL) ? 0 : currDb->AddEvent(hContact, dbei);
+ return (currDb == nullptr) ? 0 : currDb->AddEvent(hContact, dbei);
}
MIR_CORE_DLL(int) db_event_count(MCONTACT hContact)
{
- return (currDb == NULL) ? 0 : currDb->GetEventCount(hContact);
+ return (currDb == nullptr) ? 0 : currDb->GetEventCount(hContact);
}
MIR_CORE_DLL(int) db_event_delete(MCONTACT hContact, MEVENT hDbEvent)
{
- return (currDb == NULL) ? 0 : currDb->DeleteEvent(hContact, hDbEvent);
+ return (currDb == nullptr) ? 0 : currDb->DeleteEvent(hContact, hDbEvent);
}
MIR_CORE_DLL(MEVENT) db_event_first(MCONTACT hContact)
{
- return (currDb == NULL) ? 0 : currDb->FindFirstEvent(hContact);
+ return (currDb == nullptr) ? 0 : currDb->FindFirstEvent(hContact);
}
MIR_CORE_DLL(MEVENT) db_event_firstUnread(MCONTACT hContact)
{
- return (currDb == NULL) ? 0 : currDb->FindFirstUnreadEvent(hContact);
+ return (currDb == nullptr) ? 0 : currDb->FindFirstUnreadEvent(hContact);
}
MIR_CORE_DLL(int) db_event_get(MEVENT hDbEvent, DBEVENTINFO *dbei)
{
- return (currDb == NULL) ? 1 : currDb->GetEvent(hDbEvent, dbei);
+ return (currDb == nullptr) ? 1 : currDb->GetEvent(hDbEvent, dbei);
}
MIR_CORE_DLL(int) db_event_getBlobSize(MEVENT hDbEvent)
{
- return (currDb == NULL) ? 0 : currDb->GetBlobSize(hDbEvent);
+ return (currDb == nullptr) ? 0 : currDb->GetBlobSize(hDbEvent);
}
MIR_CORE_DLL(MCONTACT) db_event_getContact(MEVENT hDbEvent)
{
- return (currDb == NULL) ? 0 : currDb->GetEventContact(hDbEvent);
+ return (currDb == nullptr) ? 0 : currDb->GetEventContact(hDbEvent);
}
MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact)
{
- return (currDb == NULL) ? 0 : currDb->FindLastEvent(hContact);
+ return (currDb == nullptr) ? 0 : currDb->FindLastEvent(hContact);
}
MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent)
{
- return (currDb == NULL) ? 0 : currDb->MarkEventRead(hContact, hDbEvent);
+ return (currDb == nullptr) ? 0 : currDb->MarkEventRead(hContact, hDbEvent);
}
MIR_CORE_DLL(MEVENT) db_event_next(MCONTACT hContact, MEVENT hDbEvent)
{
- return (currDb == NULL) ? 0 : currDb->FindNextEvent(hContact, hDbEvent);
+ return (currDb == nullptr) ? 0 : currDb->FindNextEvent(hContact, hDbEvent);
}
MIR_CORE_DLL(MEVENT) db_event_prev(MCONTACT hContact, MEVENT hDbEvent)
{
- return (currDb == NULL) ? 0 : currDb->FindPrevEvent(hContact, hDbEvent);
+ return (currDb == nullptr) ? 0 : currDb->FindPrevEvent(hContact, hDbEvent);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -401,12 +401,12 @@ MIR_CORE_DLL(MEVENT) db_event_prev(MCONTACT hContact, MEVENT hDbEvent) MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv)
{
- return (currDb == NULL) ? 1 : currDb->FreeVariant(dbv);
+ return (currDb == nullptr) ? 1 : currDb->FreeVariant(dbv);
}
MIR_CORE_DLL(INT_PTR) db_unset(MCONTACT hContact, const char *szModule, const char *szSetting)
{
- if (currDb == NULL)
+ if (currDb == nullptr)
return 1;
return currDb->DeleteContactSetting(hContact, szModule, szSetting);
@@ -414,17 +414,17 @@ MIR_CORE_DLL(INT_PTR) db_unset(MCONTACT hContact, const char *szModule, const ch MIR_CORE_DLL(DBCachedContact*) db_get_contact(MCONTACT hContact)
{
- return (currDb == NULL) ? NULL : currDb->m_cache->GetCachedContact(hContact);
+ return (currDb == nullptr) ? nullptr : currDb->m_cache->GetCachedContact(hContact);
}
MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto)
{
- return (currDb == NULL) ? NULL : currDb->FindFirstContact(szProto);
+ return (currDb == nullptr) ? NULL : currDb->FindFirstContact(szProto);
}
MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto)
{
- return (currDb == NULL) ? NULL : currDb->FindNextContact(hContact, szProto);
+ return (currDb == nullptr) ? NULL : currDb->FindNextContact(hContact, szProto);
}
extern "C" MIR_CORE_DLL(void) db_setCurrent(MIDatabase *_db)
@@ -441,7 +441,7 @@ extern "C" MIR_CORE_DLL(void) db_setCurrent(MIDatabase *_db) MIR_CORE_DLL(BOOL) db_set_resident(const char *szModule, const char *szService, BOOL bEnable)
{
- if (currDb == NULL || szModule == NULL || szService == NULL)
+ if (currDb == nullptr || szModule == nullptr || szService == nullptr)
return FALSE;
char str[MAXMODULELABELLENGTH * 2];
diff --git a/src/mir_core/src/http.cpp b/src/mir_core/src/http.cpp index 1d276f647b..3b9140c1e9 100755 --- a/src/mir_core/src/http.cpp +++ b/src/mir_core/src/http.cpp @@ -23,8 +23,8 @@ static const char szHexDigits[] = "0123456789ABCDEF"; MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl)
{
- if (szUrl == NULL)
- return NULL;
+ if (szUrl == nullptr)
+ return nullptr;
const BYTE *s;
int outputLen;
@@ -37,8 +37,8 @@ MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl) }
char *szOutput = (char*)mir_alloc(outputLen+1);
- if (szOutput == NULL)
- return NULL;
+ if (szOutput == nullptr)
+ return nullptr;
char *d = szOutput;
for (s = (const BYTE*)szUrl; *s; s++) {
@@ -63,24 +63,24 @@ static char cb64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345 MIR_CORE_DLL(char*) mir_base64_encode(const BYTE *input, unsigned inputLen)
{
- if (input == NULL)
- return NULL;
+ if (input == nullptr)
+ return nullptr;
unsigned outputLen = mir_base64_encode_bufsize(inputLen);
char *output = (char*)mir_alloc(outputLen);
- if (output == NULL)
- return NULL;
+ if (output == nullptr)
+ return nullptr;
return mir_base64_encodebuf(input, inputLen, output, outputLen);
}
MIR_CORE_DLL(char*) mir_base64_encodebuf(const BYTE *input, unsigned inputLen, char *output, unsigned outputLen)
{
- if (input == NULL)
- return NULL;
+ if (input == nullptr)
+ return nullptr;
if (outputLen < mir_base64_encode_bufsize(inputLen))
- return NULL;
+ return nullptr;
char *p = output;
for (unsigned i=0; i < inputLen; ) {
@@ -128,8 +128,8 @@ static BYTE Base64DecodeTable[] = MIR_CORE_DLL(void*) mir_base64_decode(const char *input, unsigned *outputLen)
{
- if (input == NULL)
- return NULL;
+ if (input == nullptr)
+ return nullptr;
size_t length = strlen(input);
size_t nLength = (length / 4) * 3;
@@ -161,7 +161,7 @@ MIR_CORE_DLL(void*) mir_base64_decode(const char *input, unsigned *outputLen) *p = 0;
- if (outputLen != NULL)
+ if (outputLen != nullptr)
*outputLen = p - output;
return output;
diff --git a/src/mir_core/src/hyperlink.cpp b/src/mir_core/src/hyperlink.cpp index 7e777e41ad..52766da083 100644 --- a/src/mir_core/src/hyperlink.cpp +++ b/src/mir_core/src/hyperlink.cpp @@ -55,14 +55,14 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA switch (msg) {
case WM_NCCREATE:
dat = (struct HyperlinkWndData*)mir_calloc(sizeof(struct HyperlinkWndData));
- if (dat == NULL)
+ if (dat == nullptr)
return FALSE; /* fail creation */
SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat); /* always succeeds */
/* fall thru */
case WM_SYSCOLORCHANGE:
if (!(dat->flags&HLKF_HASENABLECOLOR)) {
- if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL) dat->enableColor = RGB(0, 0, 255);
+ if (GetSysColorBrush(COLOR_HOTLIGHT) == nullptr) dat->enableColor = RGB(0, 0, 255);
else dat->enableColor = GetSysColor(COLOR_HOTLIGHT);
dat->focusColor = RGB(GetRValue(dat->enableColor) / 2, GetGValue(dat->enableColor) / 2, GetBValue(dat->enableColor) / 2);
}
@@ -72,7 +72,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_SETFOCUS:
case WM_KILLFOCUS:
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
+ RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE);
break;
case WM_MOUSEACTIVATE:
@@ -113,14 +113,14 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA return 0;
case WM_SETFONT:
- if ((HFONT)wParam == NULL) { /* use default system color */
- dat->hEnableFont = dat->hDisableFont = NULL;
+ if ((HFONT)wParam == nullptr) { /* use default system color */
+ dat->hEnableFont = dat->hDisableFont = nullptr;
return 0;
}
if (GetObject((HFONT)wParam, sizeof(lf), &lf)) {
lf.lfUnderline = 1;
hFont = CreateFontIndirect(&lf);
- if (hFont != NULL) {
+ if (hFont != nullptr) {
dat->hEnableFont = hFont;
dat->hDisableFont = (HFONT)wParam;
if (LOWORD(lParam)) SendMessage(hwnd, HLK_INVALIDATE, 0, 0);
@@ -139,7 +139,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA pt.y = rc.top;
HWND hwndParent = GetParent(hwnd);
- if (hwndParent == NULL)
+ if (hwndParent == nullptr)
hwndParent = hwnd;
if (!ScreenToClient(hwndParent, &pt))
break;
@@ -164,13 +164,13 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_SETTEXT:
hdc = GetDC(hwnd);
- if (hdc == NULL) /* text change failed */
+ if (hdc == nullptr) /* text change failed */
return 0;
else {
BOOL fMeasured = FALSE;
- HFONT hPrevFont = NULL;
- if (dat->hEnableFont != NULL) hPrevFont = (HFONT)SelectObject(hdc, dat->hEnableFont);
- if (dat->hEnableFont == NULL || hPrevFont != NULL) { /* select failed? */
+ HFONT hPrevFont = nullptr;
+ if (dat->hEnableFont != nullptr) hPrevFont = (HFONT)SelectObject(hdc, dat->hEnableFont);
+ if (dat->hEnableFont == nullptr || hPrevFont != nullptr) { /* select failed? */
SIZE textSize;
if (GetTextExtentPoint32(hdc, (wchar_t*)lParam, (int)mir_wstrlen((wchar_t*)lParam), &textSize)) {
if (GetClientRect(hwnd, &rc)) {
@@ -185,7 +185,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA }
}
}
- if (dat->hEnableFont != NULL && hPrevFont != NULL)
+ if (dat->hEnableFont != nullptr && hPrevFont != nullptr)
SelectObject(hdc, hPrevFont);
ReleaseDC(hwnd, hdc);
if (!fMeasured) /* text change failed */
@@ -200,10 +200,10 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if (!ScreenToClient(hwnd, &pt)) return FALSE;
if (PtInRect(&dat->rcText, pt)) {
hCursor = (HCURSOR)GetClassLongPtr(hwnd, GCLP_HCURSOR);
- if (hCursor == NULL)
- hCursor = LoadCursor(NULL, IDC_HAND); /* Win2000+ */
+ if (hCursor == nullptr)
+ hCursor = LoadCursor(nullptr, IDC_HAND); /* Win2000+ */
}
- else hCursor = LoadCursor(NULL, IDC_ARROW);
+ else hCursor = LoadCursor(nullptr, IDC_ARROW);
SetCursor(hCursor);
return TRUE;
@@ -226,7 +226,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_PAINT:
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
- if (hdc != NULL) {
+ if (hdc != nullptr) {
HFONT hPrevFont;
COLORREF textColor;
if (IsWindowEnabled(hwnd)) {
@@ -249,13 +249,13 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA UINT alignFlag = (GetWindowLongPtr(hwnd, GWL_STYLE) & (SS_CENTER | SS_RIGHT | SS_LEFT));
DrawText(hdc, szText, -1, &rc, alignFlag | DT_NOPREFIX | DT_SINGLELINE | DT_TOP);
}
- if (hPrevFont != NULL) SelectObject(hdc, hPrevFont);
+ if (hPrevFont != nullptr) SelectObject(hdc, hPrevFont);
EndPaint(hwnd, &ps);
}
return 0;
case WM_NCDESTROY:
- if (dat->hEnableFont != NULL) DeleteObject(dat->hEnableFont);
+ if (dat->hEnableFont != nullptr) DeleteObject(dat->hEnableFont);
mir_free(dat);
break;
}
@@ -264,8 +264,8 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA void InitHyperlink(void)
{
- g_hCursorNS = LoadCursor(NULL, IDC_SIZENS);
- g_hCursorWE = LoadCursor(NULL, IDC_SIZEWE);
+ g_hCursorNS = LoadCursor(nullptr, IDC_SIZENS);
+ g_hCursorWE = LoadCursor(nullptr, IDC_SIZEWE);
WNDCLASS wcl = { 0 };
wcl.lpfnWndProc = HyperlinkWndProc;
diff --git a/src/mir_core/src/icons.cpp b/src/mir_core/src/icons.cpp index 85de384d43..28fc3d8b93 100644 --- a/src/mir_core/src/icons.cpp +++ b/src/mir_core/src/icons.cpp @@ -28,7 +28,7 @@ MIR_CORE_DLL(void) Icon_Register(HINSTANCE hInst, const char *szSection, IconIte wchar_t szFile[MAX_PATH];
GetModuleFileName(hInst, szFile, MAX_PATH);
- SKINICONDESC sid = { 0 };
+ SKINICONDESC sid = {};
sid.defaultFile.w = szFile;
sid.section.a = (char*)szSection;
sid.flags = SIDF_PATH_UNICODE;
@@ -53,7 +53,7 @@ MIR_CORE_DLL(void) Icon_RegisterT(HINSTANCE hInst, const wchar_t *szSection, Ico wchar_t szFile[MAX_PATH];
GetModuleFileName(hInst, szFile, MAX_PATH);
- SKINICONDESC sid = { 0 };
+ SKINICONDESC sid = {};
sid.defaultFile.w = szFile;
sid.section.w = (wchar_t*)szSection;
sid.flags = SIDF_ALL_UNICODE;
diff --git a/src/mir_core/src/langpack.cpp b/src/mir_core/src/langpack.cpp index fe02a5540b..81a4f2ea7b 100644 --- a/src/mir_core/src/langpack.cpp +++ b/src/mir_core/src/langpack.cpp @@ -34,8 +34,8 @@ static int CompareMuuids(const MUUID *p1, const MUUID *p2) }
static LIST<MUUID> lMuuids(10, CompareMuuids);
-static MUUID *pCurrentMuuid = NULL;
-static HANDLE hevChanged = 0;
+static MUUID *pCurrentMuuid = nullptr;
+static HANDLE hevChanged = nullptr;
static BOOL bModuleInitialized = FALSE;
@@ -134,7 +134,7 @@ MIR_CORE_DLL(unsigned int) mir_hash(const void * key, unsigned int len) static unsigned int __fastcall hashstrW(const char *key)
{
- if (key == NULL) return 0;
+ if (key == nullptr) return 0;
const unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
char *buf = (char*)alloca(len + 1);
for (unsigned i = 0; i <= len; ++i)
@@ -203,7 +203,7 @@ static bool EnterMuuid(const char *p, MUUID &result) static void LoadLangPackFile(FILE *fp, char *line)
{
while (!feof(fp)) {
- if (fgets(line, LANGPACK_BUF_SIZE, fp) == NULL)
+ if (fgets(line, LANGPACK_BUF_SIZE, fp) == nullptr)
break;
if (IsEmpty(line) || line[0] == ';' || line[0] == 0)
@@ -257,7 +257,7 @@ static void LoadLangPackFile(FILE *fp, char *line) size_t cbLen = strlen(line) - 1;
if (cFirst == '[' && line[cbLen] == ']') {
- if (g_entryCount && g_pEntries[g_entryCount-1].wszLocal == NULL)
+ if (g_entryCount && g_pEntries[g_entryCount-1].wszLocal == nullptr)
g_entryCount--;
char *pszLine = line + 1;
@@ -269,10 +269,10 @@ static void LoadLangPackFile(FILE *fp, char *line) LangPackEntry *E = &g_pEntries[g_entryCount - 1];
E->englishHash = mir_hashstr(pszLine);
- E->szLocal = NULL;
- E->wszLocal = NULL;
+ E->szLocal = nullptr;
+ E->wszLocal = nullptr;
E->pMuuid = pCurrentMuuid;
- E->pNext = NULL;
+ E->pNext = nullptr;
continue;
}
@@ -280,8 +280,8 @@ static void LoadLangPackFile(FILE *fp, char *line) continue;
LangPackEntry *E = &g_pEntries[g_entryCount - 1];
- int iNeeded = MultiByteToWideChar(CP_UTF8, 0, line, -1, 0, 0), iOldLen;
- if (E->wszLocal == NULL) {
+ int iNeeded = MultiByteToWideChar(CP_UTF8, 0, line, -1, nullptr, 0), iOldLen;
+ if (E->wszLocal == nullptr) {
iOldLen = 0;
E->wszLocal = (wchar_t *)mir_alloc((iNeeded + 1) * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, line, -1, E->wszLocal, iNeeded);
@@ -315,7 +315,7 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start // headers
while (!feof(fp)) {
startOfLine = ftell(fp);
- if (fgets(line, LANGPACK_BUF_SIZE, fp) == NULL)
+ if (fgets(line, LANGPACK_BUF_SIZE, fp) == nullptr)
break;
lrtrim(line);
@@ -326,7 +326,7 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start break;
char *pszColon = strchr(line, ':');
- if (pszColon == NULL)
+ if (pszColon == nullptr)
return 3;
*pszColon++ = 0;
@@ -365,16 +365,16 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start if (!lpinfo.tszLanguage[0] && (lpinfo.Locale == 0) || !GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, _countof(lpinfo.tszLanguage))) {
wchar_t *p = wcschr(lpinfo.tszFileName, '_');
- wcsncpy_s(lpinfo.tszLanguage, ((p != NULL) ? (p + 1) : lpinfo.tszFileName), _TRUNCATE);
+ wcsncpy_s(lpinfo.tszLanguage, ((p != nullptr) ? (p + 1) : lpinfo.tszFileName), _TRUNCATE);
p = wcsrchr(lpinfo.tszLanguage, '.');
- if (p != NULL) *p = '\0';
+ if (p != nullptr) *p = '\0';
}
return 0;
}
MIR_CORE_DLL(int) LoadLangPack(const wchar_t *ptszLangPack)
{
- if (ptszLangPack == NULL || !mir_wstrcmpi(ptszLangPack, L""))
+ if (ptszLangPack == nullptr || !mir_wstrcmpi(ptszLangPack, L""))
return 1;
// ensure that a lang's name is a full file name
@@ -400,11 +400,11 @@ MIR_CORE_DLL(int) LoadLangPack(const wchar_t *ptszLangPack) // copy the full file name and extract a file name from it
wcsncpy_s(langPack.tszFullPath, tszFullPath, _TRUNCATE);
wchar_t *p = wcsrchr(langPack.tszFullPath, '\\');
- wcsncpy_s(langPack.tszFileName, (p == NULL) ? tszFullPath : p + 1, _TRUNCATE);
+ wcsncpy_s(langPack.tszFileName, (p == nullptr) ? tszFullPath : p + 1, _TRUNCATE);
CharLower(langPack.tszFileName);
FILE *fp = _wfopen(tszFullPath, L"rt");
- if (fp == NULL)
+ if (fp == nullptr)
return 1;
char line[LANGPACK_BUF_SIZE] = "";
@@ -419,7 +419,7 @@ MIR_CORE_DLL(int) LoadLangPack(const wchar_t *ptszLangPack) LoadLangPackFile(fp, line);
fclose(fp);
- pCurrentMuuid = NULL;
+ pCurrentMuuid = nullptr;
qsort(g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
return 0;
@@ -427,16 +427,16 @@ MIR_CORE_DLL(int) LoadLangPack(const wchar_t *ptszLangPack) MIR_CORE_DLL(int) LoadLangPackDescr(const wchar_t *ptszLangPack, LANGPACK_INFO *lpInfo)
{
- if (lpInfo == NULL)
+ if (lpInfo == nullptr)
return 1;
wcsncpy_s(lpInfo->tszFullPath, ptszLangPack, _TRUNCATE);
wchar_t *p = wcsrchr(lpInfo->tszFullPath, '\\');
- wcsncpy_s(lpInfo->tszFileName, (p == NULL) ? ptszLangPack : p+1, _TRUNCATE);
+ wcsncpy_s(lpInfo->tszFileName, (p == nullptr) ? ptszLangPack : p+1, _TRUNCATE);
CharLower(lpInfo->tszFileName);
FILE *fp = _wfopen(ptszLangPack, L"rt");
- if (fp == NULL)
+ if (fp == nullptr)
return 1;
char line[LANGPACK_BUF_SIZE] = "";
@@ -457,18 +457,18 @@ static int SortLangPackHashesProc2(LangPackEntry *arg1, LangPackEntry *arg2) char* LangPackTranslateString(MUUID *pUuid, const char *szEnglish, const int W)
{
- if (g_entryCount == 0 || szEnglish == NULL)
+ if (g_entryCount == 0 || szEnglish == nullptr)
return (char*)szEnglish;
LangPackEntry key, *entry;
key.englishHash = W ? hashstrW(szEnglish) : mir_hashstr(szEnglish);
entry = (LangPackEntry*)bsearch(&key, g_pEntries, g_entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc2);
- if (entry == NULL)
+ if (entry == nullptr)
return (char*)szEnglish;
// try to find the exact match, otherwise the first entry will be returned
if (pUuid) {
- for (LangPackEntry *p = entry->pNext; p != NULL; p = p->pNext) {
+ for (LangPackEntry *p = entry->pNext; p != nullptr; p = p->pNext) {
if (p->pMuuid == pUuid) {
entry = p;
break;
@@ -479,7 +479,7 @@ char* LangPackTranslateString(MUUID *pUuid, const char *szEnglish, const int W) if (W)
return (char*)entry->wszLocal;
- if (entry->szLocal == NULL && entry->wszLocal != NULL)
+ if (entry->szLocal == nullptr && entry->wszLocal != nullptr)
entry->szLocal = mir_u2a_cp(entry->wszLocal, langPack.codepage);
return entry->szLocal;
}
@@ -496,8 +496,8 @@ MIR_CORE_DLL(int) Langpack_GetDefaultLocale() MIR_CORE_DLL(wchar_t*) Langpack_PcharToTchar(const char *pszStr)
{
- if (pszStr == NULL)
- return NULL;
+ if (pszStr == nullptr)
+ return nullptr;
int len = (int)strlen(pszStr);
wchar_t *result = (wchar_t*)alloca((len + 1)*sizeof(wchar_t));
@@ -541,7 +541,7 @@ MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, int _hLangpack) }
}
- if (mii.hSubMenu != NULL)
+ if (mii.hSubMenu != nullptr)
TranslateMenu_LP(mii.hSubMenu, _hLangpack);
}
}
@@ -583,7 +583,7 @@ MIR_CORE_DLL(void) TranslateDialog_LP(HWND hDlg, int _hLangpack) MIR_CORE_DLL(MUUID*) Langpack_LookupUuid(WPARAM wParam)
{
int idx = (wParam >> 16) & 0xFFFF;
- return (idx > 0 && idx <= lMuuids.getCount()) ? lMuuids[idx - 1] : NULL;
+ return (idx > 0 && idx <= lMuuids.getCount()) ? lMuuids[idx - 1] : nullptr;
}
MIR_CORE_DLL(int) Langpack_MarkPluginLoaded(PLUGININFOEX *pInfo)
@@ -693,7 +693,7 @@ MIR_CORE_DLL(void) mir_getLP(const PLUGININFOEX *pInfo, int *_hLang) MIR_CORE_DLL(void) ReloadLangpack(wchar_t *pszStr)
{
- if (pszStr == NULL)
+ if (pszStr == nullptr)
pszStr = NEWWSTR_ALLOCA(langPack.tszFileName);
UnloadLangPackModule();
@@ -731,8 +731,8 @@ void UnloadLangPackModule() LangPackEntry *p = g_pEntries;
for (i = 0; i < g_entryCount; i++, p++) {
- if (p->pNext != NULL) {
- for (LangPackEntry *p1 = p->pNext; p1 != NULL;) {
+ if (p->pNext != nullptr) {
+ for (LangPackEntry *p1 = p->pNext; p1 != nullptr;) {
LangPackEntry *p2 = p1; p1 = p1->pNext;
mir_free(p2->szLocal);
mir_free(p2->wszLocal);
@@ -746,7 +746,7 @@ void UnloadLangPackModule() if (g_entryCount) {
mir_free(g_pEntries);
- g_pEntries = 0;
+ g_pEntries = nullptr;
g_entryCount = g_entriesAlloced = 0;
}
diff --git a/src/mir_core/src/lists.cpp b/src/mir_core/src/lists.cpp index 431da56081..310b53f4ae 100644 --- a/src/mir_core/src/lists.cpp +++ b/src/mir_core/src/lists.cpp @@ -29,8 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. MIR_CORE_DLL(SortedList*) List_Create(int p_limit, int p_increment)
{
SortedList* result = (SortedList*)mir_calloc(sizeof(SortedList));
- if (result == NULL)
- return(NULL);
+ if (result == nullptr)
+ return(nullptr);
result->increment = p_increment;
result->limit = p_limit;
@@ -39,12 +39,12 @@ MIR_CORE_DLL(SortedList*) List_Create(int p_limit, int p_increment) MIR_CORE_DLL(void) List_Destroy(SortedList* p_list)
{
- if (p_list == NULL)
+ if (p_list == nullptr)
return;
- if (p_list->items != NULL) {
+ if (p_list->items != nullptr) {
mir_free(p_list->items);
- p_list->items = NULL;
+ p_list->items = nullptr;
}
p_list->realCount = p_list->limit = 0;
@@ -54,7 +54,7 @@ MIR_CORE_DLL(void*) List_Find(SortedList* p_list, void* p_value) {
int idx;
if (!List_GetIndex(p_list, p_value, &idx))
- return NULL;
+ return nullptr;
return p_list->items[idx];
}
@@ -65,7 +65,7 @@ MIR_CORE_DLL(void*) List_Find(SortedList* p_list, void* p_value) MIR_CORE_DLL(int) List_GetIndex(SortedList* p_list, void* p_value, int* p_index)
{
- if (p_value == NULL || p_list->sortFunc == NULL) {
+ if (p_value == nullptr || p_list->sortFunc == nullptr) {
*p_index = -1;
return 0;
}
@@ -155,7 +155,7 @@ MIR_CORE_DLL(int) List_GetIndex(SortedList* p_list, void* p_value, int* p_index) MIR_CORE_DLL(int) List_IndexOf(SortedList* p_list, void* p_value)
{
- if (p_value == NULL)
+ if (p_value == nullptr)
return -1;
for (int i = 0; i < p_list->realCount; i++)
@@ -171,7 +171,7 @@ MIR_CORE_DLL(int) List_IndexOf(SortedList* p_list, void* p_value) MIR_CORE_DLL(int) List_Insert(SortedList* p_list, void* p_value, int p_index)
{
- if (p_value == NULL || p_index > p_list->realCount)
+ if (p_value == nullptr || p_index > p_list->realCount)
return 0;
if (p_list->realCount == p_list->limit) {
@@ -190,11 +190,11 @@ MIR_CORE_DLL(int) List_Insert(SortedList* p_list, void* p_value, int p_index) MIR_CORE_DLL(int) List_InsertPtr(SortedList* list, void* p)
{
- if (p == NULL)
+ if (p == nullptr)
return -1;
int idx;
- if (list->sortFunc == 0)
+ if (list->sortFunc == nullptr)
idx = list->realCount;
else
List_GetIndex(list, p, &idx);
@@ -209,7 +209,7 @@ MIR_CORE_DLL(int) List_Remove(SortedList* p_list, int index) p_list->realCount--;
if (p_list->realCount > index) {
memmove(p_list->items + index, p_list->items + index + 1, sizeof(void*)*(p_list->realCount - index));
- p_list->items[p_list->realCount] = NULL;
+ p_list->items[p_list->realCount] = nullptr;
}
return 1;
diff --git a/src/mir_core/src/logger.cpp b/src/mir_core/src/logger.cpp index 561d34f1f1..0b5d858fc3 100644 --- a/src/mir_core/src/logger.cpp +++ b/src/mir_core/src/logger.cpp @@ -34,7 +34,7 @@ struct Logger m_fileName(mir_wstrdup(ptszFilename)),
m_options(options),
m_signature(SECRET_SIGNATURE),
- m_out(NULL),
+ m_out(nullptr),
m_lastwrite(0)
{
}
@@ -85,7 +85,7 @@ void CheckLogs() mir_cslock lck(p.m_cs);
if (p.m_out && li.QuadPart - p.m_lastwrite > llIdlePeriod) {
fclose(p.m_out);
- p.m_out = NULL;
+ p.m_out = nullptr;
}
else fflush(p.m_out);
}
@@ -95,12 +95,12 @@ void CheckLogs() MIR_CORE_DLL(HANDLE) mir_createLog(const char* pszName, const wchar_t *ptszDescr, const wchar_t *ptszFile, unsigned options)
{
- if (ptszFile == NULL)
- return NULL;
+ if (ptszFile == nullptr)
+ return nullptr;
Logger *result = new Logger(pszName, ptszDescr, ptszFile, options);
- if (result == NULL)
- return NULL;
+ if (result == nullptr)
+ return nullptr;
int idx = arLoggers.getIndex(result);
if (idx != -1) {
@@ -109,7 +109,7 @@ MIR_CORE_DLL(HANDLE) mir_createLog(const char* pszName, const wchar_t *ptszDescr }
FILE *fp = _wfopen(ptszFile, L"ab");
- if (fp == NULL) {
+ if (fp == nullptr) {
wchar_t tszPath[MAX_PATH];
wcsncpy_s(tszPath, ptszFile, _TRUNCATE);
CreatePathToFileW(tszPath);
@@ -125,17 +125,17 @@ MIR_CORE_DLL(HANDLE) mir_createLog(const char* pszName, const wchar_t *ptszDescr static Logger* prepareLogger(HANDLE hLogger)
{
- if (hLogger == NULL)
- return NULL;
+ if (hLogger == nullptr)
+ return nullptr;
Logger *p = (Logger*)hLogger;
- return (p->m_signature == SECRET_SIGNATURE) ? p : NULL;
+ return (p->m_signature == SECRET_SIGNATURE) ? p : nullptr;
}
MIR_CORE_DLL(void) mir_closeLog(HANDLE hLogger)
{
Logger *p = prepareLogger(hLogger);
- if (p != NULL)
+ if (p != nullptr)
arLoggers.remove(p);
}
@@ -144,12 +144,12 @@ MIR_CORE_DLL(void) mir_closeLog(HANDLE hLogger) MIR_C_CORE_DLL(int) mir_writeLogA(HANDLE hLogger, const char *format, ...)
{
Logger *p = prepareLogger(hLogger);
- if (p == NULL)
+ if (p == nullptr)
return 1;
mir_cslock lck(p->m_cs);
- if (p->m_out == NULL)
- if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == NULL)
+ if (p->m_out == nullptr)
+ if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == nullptr)
return 2;
va_list args;
@@ -166,12 +166,12 @@ MIR_C_CORE_DLL(int) mir_writeLogA(HANDLE hLogger, const char *format, ...) MIR_C_CORE_DLL(int) mir_writeLogW(HANDLE hLogger, const WCHAR *format, ...)
{
Logger *p = prepareLogger(hLogger);
- if (p == NULL)
+ if (p == nullptr)
return 1;
mir_cslock lck(p->m_cs);
- if (p->m_out == NULL)
- if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == NULL)
+ if (p->m_out == nullptr)
+ if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == nullptr)
return 2;
va_list args;
@@ -190,12 +190,12 @@ MIR_C_CORE_DLL(int) mir_writeLogW(HANDLE hLogger, const WCHAR *format, ...) MIR_CORE_DLL(int) mir_writeLogVA(HANDLE hLogger, const char *format, va_list args)
{
Logger *p = prepareLogger(hLogger);
- if (p == NULL)
+ if (p == nullptr)
return 1;
mir_cslock lck(p->m_cs);
- if (p->m_out == NULL)
- if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == NULL)
+ if (p->m_out == nullptr)
+ if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == nullptr)
return 2;
vfprintf(p->m_out, format, args);
@@ -209,12 +209,12 @@ MIR_CORE_DLL(int) mir_writeLogVA(HANDLE hLogger, const char *format, va_list arg MIR_CORE_DLL(int) mir_writeLogVW(HANDLE hLogger, const WCHAR *format, va_list args)
{
Logger *p = prepareLogger(hLogger);
- if (p == NULL)
+ if (p == nullptr)
return 1;
mir_cslock lck(p->m_cs);
- if (p->m_out == NULL)
- if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == NULL)
+ if (p->m_out == nullptr)
+ if ((p->m_out = _wfopen(p->m_fileName, L"ab")) == nullptr)
return 2;
vfwprintf(p->m_out, format, args);
diff --git a/src/mir_core/src/mc.cpp b/src/mir_core/src/mc.cpp index 919024e1da..01c710137e 100644 --- a/src/mir_core/src/mc.cpp +++ b/src/mir_core/src/mc.cpp @@ -36,10 +36,10 @@ void InitMetaContacts() DBCachedContact* CheckMeta(MCONTACT hMeta)
{
if (!g_bEnabled)
- return NULL;
+ return nullptr;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hMeta);
- return (cc == NULL || cc->nSubs == -1) ? NULL : cc;
+ return (cc == nullptr || cc->nSubs == -1) ? nullptr : cc;
}
int Meta_GetContactNumber(DBCachedContact *cc, MCONTACT hContact)
@@ -77,25 +77,25 @@ MIR_CORE_DLL(void) db_mc_enable(BOOL bEnabled) MIR_CORE_DLL(BOOL) db_mc_isMeta(MCONTACT hContact)
{
- if (currDb == NULL || !g_bEnabled) return FALSE;
+ if (currDb == nullptr || !g_bEnabled) return FALSE;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- return (cc == NULL) ? FALSE : cc->nSubs != -1;
+ return (cc == nullptr) ? FALSE : cc->nSubs != -1;
}
MIR_CORE_DLL(BOOL) db_mc_isSub(MCONTACT hContact)
{
- if (currDb == NULL || !g_bEnabled) return FALSE;
+ if (currDb == nullptr || !g_bEnabled) return FALSE;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- return (cc == NULL) ? FALSE : cc->parentID != 0;
+ return (cc == nullptr) ? FALSE : cc->parentID != 0;
}
//returns a handle to the default contact, or null on failure
MIR_CORE_DLL(MCONTACT) db_mc_getDefault(MCONTACT hMetaContact)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
- if (cc == NULL)
+ if (cc == nullptr)
return 0;
return (cc->nDefault != -1) ? Meta_GetContactHandle(cc, cc->nDefault) : 0;
@@ -105,32 +105,32 @@ MIR_CORE_DLL(MCONTACT) db_mc_getDefault(MCONTACT hMetaContact) MIR_CORE_DLL(int) db_mc_getDefaultNum(MCONTACT hMetaContact)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? -1 : cc->nDefault;
+ return (cc == nullptr) ? -1 : cc->nDefault;
}
//returns the number of subcontacts, or -1 on failure
MIR_CORE_DLL(int) db_mc_getSubCount(MCONTACT hMetaContact)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? -1 : cc->nSubs;
+ return (cc == nullptr) ? -1 : cc->nSubs;
}
// returns parent hContact for a subcontact or NULL if it's not a sub
MIR_CORE_DLL(MCONTACT) db_mc_getMeta(MCONTACT hSubContact)
{
- if (currDb == NULL) return NULL;
+ if (currDb == nullptr) return NULL;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hSubContact);
- return (cc == NULL) ? NULL : cc->parentID;
+ return (cc == nullptr) ? NULL : cc->parentID;
}
// returns parent hContact for a subcontact or hContact itself if it's not a sub
MIR_CORE_DLL(MCONTACT) db_mc_tryMeta(MCONTACT hContact)
{
- if (currDb == NULL) return hContact;
+ if (currDb == nullptr) return hContact;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL) return hContact;
+ if (cc == nullptr) return hContact;
return (cc->IsSub()) ? cc->parentID : hContact;
}
@@ -139,14 +139,14 @@ MIR_CORE_DLL(MCONTACT) db_mc_tryMeta(MCONTACT hContact) MIR_CORE_DLL(MCONTACT) db_mc_getSub(MCONTACT hMetaContact, int iNum)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
- return (cc == NULL) ? 0 : Meta_GetContactHandle(cc, iNum);
+ return (cc == nullptr) ? 0 : Meta_GetContactHandle(cc, iNum);
}
//sets the default contact, using the subcontact's handle
MIR_CORE_DLL(int) db_mc_setDefault(MCONTACT hMetaContact, MCONTACT hSub, BOOL bWriteDb)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
- if (cc == NULL)
+ if (cc == nullptr)
return 1;
int contact_number = Meta_GetContactNumber(cc, hSub);
@@ -167,7 +167,7 @@ MIR_CORE_DLL(int) db_mc_setDefault(MCONTACT hMetaContact, MCONTACT hSub, BOOL bW MIR_CORE_DLL(int) db_mc_setDefaultNum(MCONTACT hMetaContact, int iNum, BOOL bWriteDb)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
- if (cc == NULL)
+ if (cc == nullptr)
return 1;
if (iNum >= cc->nSubs || iNum < 0)
return 1;
diff --git a/src/mir_core/src/md5.cpp b/src/mir_core/src/md5.cpp index 817cd68b9a..6cb8419249 100644 --- a/src/mir_core/src/md5.cpp +++ b/src/mir_core/src/md5.cpp @@ -146,7 +146,7 @@ static void md5_process(mir_md5_state_t *pms, const BYTE *data /*[64]*/) * On little-endian machines, we can process properly aligned
* data without copying it.
*/
- if ( !((data - (const BYTE *)0) & 3)) {
+ if ( !((data - (const BYTE *)nullptr) & 3)) {
/* data are properly aligned */
X = (const UINT32 *)data;
} else {
diff --git a/src/mir_core/src/memory.cpp b/src/mir_core/src/memory.cpp index 9a600a83e1..1d404ca313 100644 --- a/src/mir_core/src/memory.cpp +++ b/src/mir_core/src/memory.cpp @@ -67,15 +67,15 @@ static int CheckBlock(void* blk) MIR_C_CORE_DLL(void*) mir_alloc(size_t size)
{
if (size == 0)
- return NULL;
+ return nullptr;
char *p = (char*)malloc(size + sizeof(DWORD)* 3);
- if (p == NULL) {
+ if (p == nullptr) {
OutputDebugStringA("memory overflow\n");
#if defined(_DEBUG)
DebugBreak();
#endif
- return NULL;
+ return nullptr;
}
*(DWORD*)p = (DWORD)size;
@@ -89,7 +89,7 @@ MIR_C_CORE_DLL(void*) mir_alloc(size_t size) MIR_C_CORE_DLL(void*) mir_calloc(size_t size)
{
void* p = mir_alloc(size);
- if (p != NULL)
+ if (p != nullptr)
memset(p, 0, size);
return p;
}
@@ -100,20 +100,20 @@ MIR_C_CORE_DLL(void*) mir_realloc(void* ptr, size_t size) {
char *p;
- if (ptr != NULL) {
+ if (ptr != nullptr) {
if (!CheckBlock(ptr))
- return NULL;
+ return nullptr;
p = (char*)ptr - sizeof(DWORD)*2;
}
- else p = NULL;
+ else p = nullptr;
p = (char*)realloc(p, size + sizeof(DWORD)*3);
- if (p == NULL) {
+ if (p == nullptr) {
OutputDebugStringA("memory overflow\n");
#if defined(_DEBUG)
DebugBreak();
#endif
- return NULL;
+ return nullptr;
}
*(DWORD*)p = (DWORD)size;
@@ -129,7 +129,7 @@ MIR_C_CORE_DLL(void) mir_free(void* ptr) char* p;
DWORD size;
- if (ptr == NULL)
+ if (ptr == nullptr)
return;
if (!CheckBlock(ptr))
return;
@@ -146,8 +146,8 @@ MIR_C_CORE_DLL(void) mir_free(void* ptr) MIR_CORE_DLL(char*) mir_strdup(const char *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
char *p = (char*)mir_alloc(strlen(str)+1);
if (p)
@@ -157,8 +157,8 @@ MIR_CORE_DLL(char*) mir_strdup(const char *str) MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
if (p)
@@ -170,8 +170,8 @@ MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR *str) MIR_CORE_DLL(char*) mir_strndup(const char *str, size_t len)
{
- if (str == NULL || len == 0)
- return NULL;
+ if (str == nullptr || len == 0)
+ return nullptr;
char *p = (char*)mir_alloc(len+1);
if (p) {
@@ -183,8 +183,8 @@ MIR_CORE_DLL(char*) mir_strndup(const char *str, size_t len) MIR_CORE_DLL(WCHAR*) mir_wstrndup(const WCHAR *str, size_t len)
{
- if (str == NULL || len == 0)
- return NULL;
+ if (str == nullptr || len == 0)
+ return nullptr;
WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(len+1));
if (p) {
@@ -240,13 +240,13 @@ MIR_CORE_DLL(int) mir_vsnwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, MIR_CORE_DLL(wchar_t*) mir_a2u_cp(const char* src, int codepage)
{
- if (src == NULL)
- return NULL;
+ if (src == nullptr)
+ return nullptr;
- int cbLen = MultiByteToWideChar(codepage, 0, src, -1, NULL, 0);
+ int cbLen = MultiByteToWideChar(codepage, 0, src, -1, nullptr, 0);
wchar_t* result = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen+1));
- if (result == NULL)
- return NULL;
+ if (result == nullptr)
+ return nullptr;
MultiByteToWideChar(codepage, 0, src, -1, result, cbLen);
result[cbLen] = 0;
@@ -264,15 +264,15 @@ MIR_CORE_DLL(wchar_t*) mir_a2u(const char* src) MIR_CORE_DLL(char*) mir_u2a_cp(const wchar_t* src, int codepage)
{
- if (src == NULL)
- return NULL;
+ if (src == nullptr)
+ return nullptr;
- int cbLen = WideCharToMultiByte(codepage, 0, src, -1, NULL, 0, NULL, NULL);
+ int cbLen = WideCharToMultiByte(codepage, 0, src, -1, nullptr, 0, nullptr, nullptr);
char* result = (char*)mir_alloc(cbLen+1);
- if (result == NULL)
- return NULL;
+ if (result == nullptr)
+ return nullptr;
- WideCharToMultiByte(codepage, 0, src, -1, result, cbLen, NULL, NULL);
+ WideCharToMultiByte(codepage, 0, src, -1, result, cbLen, nullptr, nullptr);
result[cbLen] = 0;
return result;
}
diff --git a/src/mir_core/src/miranda.cpp b/src/mir_core/src/miranda.cpp index 28a9a99c63..79abdf9d4c 100644 --- a/src/mir_core/src/miranda.cpp +++ b/src/mir_core/src/miranda.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-HWND hAPCWindow = NULL;
+HWND hAPCWindow = nullptr;
int InitPathUtils(void);
void RecalculateTime(void);
@@ -41,7 +41,7 @@ void InitTimeZones(); void InitWinver();
int hLangpack = 0;
-HINSTANCE g_hInst = 0;
+HINSTANCE g_hInst = nullptr;
HCURSOR g_hCursorNS, g_hCursorWE;
HANDLE hStackMutex, hThreadQueueEmpty;
@@ -55,7 +55,7 @@ static INT_PTR RestartMiranda(WPARAM wParam, LPARAM lParam) if (lParam)
wcsncpy_s(mirandaPath, (const wchar_t*)lParam, _TRUNCATE);
else
- GetModuleFileName(NULL, mirandaPath, _countof(mirandaPath));
+ GetModuleFileName(nullptr, mirandaPath, _countof(mirandaPath));
if (wParam) {
VARSW profilename(L"%miranda_profilename%");
@@ -68,7 +68,7 @@ static INT_PTR RestartMiranda(WPARAM wParam, LPARAM lParam) PROCESS_INFORMATION pi;
STARTUPINFO startupInfo = { 0 };
startupInfo.cb = sizeof(startupInfo);
- CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &pi);
+ CreateProcess(mirandaPath, cmdLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startupInfo, &pi);
return 0;
}
@@ -99,15 +99,15 @@ static void LoadCoreModule(void) icce.dwICC = ICC_WIN95_CLASSES | ICC_USEREX_CLASSES;
InitCommonControlsEx(&icce);
- hAPCWindow = CreateWindowEx(0, L"ComboLBox", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
+ hAPCWindow = CreateWindowEx(0, L"ComboLBox", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);
SetClassLongPtr(hAPCWindow, GCL_STYLE, GetClassLongPtr(hAPCWindow, GCL_STYLE) | CS_DROPSHADOW);
DestroyWindow(hAPCWindow);
- hAPCWindow = CreateWindowEx(0, L"STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
+ hAPCWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);
SetWindowLongPtr(hAPCWindow, GWLP_WNDPROC, (LONG_PTR)APCWndProc);
- SetTimer(hAPCWindow, 1, 1000, NULL);
- hStackMutex = CreateMutex(NULL, FALSE, NULL);
- hThreadQueueEmpty = CreateEvent(NULL, TRUE, TRUE, NULL);
+ SetTimer(hAPCWindow, 1, 1000, nullptr);
+ hStackMutex = CreateMutex(nullptr, FALSE, nullptr);
+ hThreadQueueEmpty = CreateEvent(nullptr, TRUE, TRUE, nullptr);
InitWinver();
InitPathUtils();
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index 34fa24fec9..d287f01319 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -84,8 +84,8 @@ static int sttHookId = 1; __forceinline HANDLE getThreadEvent() { HANDLE pData = (HANDLE)TlsGetValue(mir_tls); - if (pData == NULL) { - pData = CreateEvent(NULL, FALSE, FALSE, NULL); + if (pData == nullptr) { + pData = CreateEvent(nullptr, FALSE, FALSE, nullptr); TlsSetValue(mir_tls, pData); } return pData; @@ -105,8 +105,8 @@ static int QueueMainThread(PAPCFUNC pFunc, void* pParam, HANDLE hDoneEvent) MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name) { - if (name == NULL) - return NULL; + if (name == nullptr) + return nullptr; mir_cslock lck(csHooks); @@ -118,8 +118,8 @@ MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name) strncpy(newItem->name, name, sizeof(newItem->name)); newItem->name[MAXMODULELABELLENGTH - 1] = 0; newItem->id = sttHookId++; newItem->subscriberCount = 0; - newItem->subscriber = NULL; - newItem->pfnHook = NULL; + newItem->subscriber = nullptr; + newItem->pfnHook = nullptr; newItem->secretSignature = HOOK_SECRET_SIGNATURE; InitializeCriticalSection(&newItem->csHook); hooks.insert(newItem); @@ -128,7 +128,7 @@ MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name) MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent) { - if (hEvent == NULL) + if (hEvent == nullptr) return 1; mir_cslock lck(csHooks); @@ -141,7 +141,7 @@ MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent) p->secretSignature = 0; if (p->subscriberCount) { mir_free(p->subscriber); - p->subscriber = NULL; + p->subscriber = nullptr; p->subscriberCount = 0; } hooks.remove(idx); @@ -163,7 +163,7 @@ MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnH MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam) { THook *p = (THook*)hEvent; - if (p == NULL || hInst == NULL) + if (p == nullptr || hInst == nullptr) return -1; mir_cslock lck(p->csHook); @@ -185,7 +185,7 @@ MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wPa return returnVal; } - if (p->subscriberCount == 0 && p->pfnHook != 0) + if (p->subscriberCount == 0 && p->pfnHook != nullptr) return p->pfnHook(wParam, lParam); return 0; @@ -193,7 +193,7 @@ MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wPa static int CallHookSubscribers(THook *p, WPARAM wParam, LPARAM lParam) { - if (p == NULL) + if (p == nullptr) return -1; mir_cslock lck(p->csHook); @@ -216,7 +216,7 @@ static int CallHookSubscribers(THook *p, WPARAM wParam, LPARAM lParam) } // call the default hook if any - if (p->pfnHook != 0) + if (p->pfnHook != nullptr) return p->pfnHook(wParam, lParam); return 0; @@ -226,14 +226,14 @@ enum { hookOk, hookEmpty, hookInvalid }; int checkHook(THook *p) { - if (p == NULL) + if (p == nullptr) return hookInvalid; int ret; __try { if (p->secretSignature != HOOK_SECRET_SIGNATURE) ret = hookInvalid; - else if (p->subscriberCount == 0 && p->pfnHook == NULL) + else if (p->subscriberCount == 0 && p->pfnHook == nullptr) ret = hookEmpty; else ret = hookOk; @@ -297,7 +297,7 @@ static HANDLE HookEventInt(int type, const char *name, MIRANDAHOOK hookProc, voi int idx; if ((idx = hooks.getIndex((THook*)name)) == -1) - return NULL; + return nullptr; THook *p = hooks[idx]; p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount + 1)); @@ -315,12 +315,12 @@ static HANDLE HookEventInt(int type, const char *name, MIRANDAHOOK hookProc, voi MIR_CORE_DLL(HANDLE) HookEvent(const char *name, MIRANDAHOOK hookProc) { - return HookEventInt(1, name, hookProc, 0, 0); + return HookEventInt(1, name, hookProc, nullptr, 0); } MIR_CORE_DLL(HANDLE) HookEventParam(const char *name, MIRANDAHOOKPARAM hookProc, LPARAM lParam) { - return HookEventInt(2, name, (MIRANDAHOOK)hookProc, 0, lParam); + return HookEventInt(2, name, (MIRANDAHOOK)hookProc, nullptr, lParam); } MIR_CORE_DLL(HANDLE) HookEventObj(const char *name, MIRANDAHOOKOBJ hookProc, void* object) @@ -341,7 +341,7 @@ MIR_CORE_DLL(HANDLE) HookTemporaryEvent(const char *name, MIRANDAHOOK hookProc) if ((idx = hooks.getIndex((THook*)name)) == -1) { lck.unlock(); hookProc(0, 0); - return NULL; + return nullptr; } THook *p = hooks[idx]; @@ -363,7 +363,7 @@ MIR_CORE_DLL(HANDLE) HookEventMessage(const char *name, HWND hwnd, UINT message) int idx; if ((idx = hooks.getIndex((THook*)name)) == -1) - return NULL; + return nullptr; THook *p = hooks[idx]; p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount + 1)); @@ -376,7 +376,7 @@ MIR_CORE_DLL(HANDLE) HookEventMessage(const char *name, HWND hwnd, UINT message) MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook) { - if (hHook == NULL) + if (hHook == nullptr) return 0; int hookId = (INT_PTR)hHook >> 16; @@ -384,27 +384,27 @@ MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook) mir_cslock lck(csHooks); - THook *p = NULL; + THook *p = nullptr; for (int i = 0; i < hooks.getCount(); i++) if (hooks[i]->id == hookId) { p = hooks[i]; break; } - if (p == NULL) + if (p == nullptr) return 1; if (subscriberId >= p->subscriberCount || subscriberId < 0) return 1; p->subscriber[subscriberId].type = 0; - p->subscriber[subscriberId].pfnHook = NULL; - p->subscriber[subscriberId].hOwner = NULL; + p->subscriber[subscriberId].pfnHook = nullptr; + p->subscriber[subscriberId].hOwner = nullptr; while (p->subscriberCount && p->subscriber[p->subscriberCount - 1].type == 0) p->subscriberCount--; if (p->subscriberCount == 0) { mir_free(p->subscriber); - p->subscriber = NULL; + p->subscriber = nullptr; } return 0; } @@ -471,8 +471,8 @@ static __inline TService* FindServiceByName(const char *name) static HANDLE CreateServiceInt(int type, const char *name, MIRANDASERVICE serviceProc, void* object, LPARAM lParam) { - if (name == NULL) - return NULL; + if (name == nullptr) + return nullptr; TService tmp; tmp.nameHash = mir_hashstr(name); @@ -480,7 +480,7 @@ static HANDLE CreateServiceInt(int type, const char *name, MIRANDASERVICE servic mir_cslock lck(csServices); if (services.getIndex(&tmp) != -1) - return NULL; + return nullptr; TService* p = (TService*)mir_alloc(sizeof(*p) + strlen(name)); strcpy(p->name, name); @@ -497,12 +497,12 @@ static HANDLE CreateServiceInt(int type, const char *name, MIRANDASERVICE servic MIR_CORE_DLL(HANDLE) CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc) { - return CreateServiceInt(0, name, serviceProc, 0, 0); + return CreateServiceInt(0, name, serviceProc, nullptr, 0); } MIR_CORE_DLL(HANDLE) CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam) { - return CreateServiceInt(1, name, (MIRANDASERVICE)serviceProc, 0, lParam); + return CreateServiceInt(1, name, (MIRANDASERVICE)serviceProc, nullptr, lParam); } MIR_CORE_DLL(HANDLE) CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object) @@ -538,22 +538,22 @@ MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService) MIR_CORE_DLL(bool) ServiceExists(const char *name) { - if (name == NULL) + if (name == nullptr) return FALSE; mir_cslock lck(csServices); - return FindServiceByName(name) != NULL; + return FindServiceByName(name) != nullptr; } MIR_CORE_DLL(INT_PTR) CallService(const char *name, WPARAM wParam, LPARAM lParam) { - if (name == NULL) + if (name == nullptr) return CALLSERVICE_NOTFOUND; TService *pService; { mir_cslock lck(csServices); - if ((pService = FindServiceByName(name)) == NULL) + if ((pService = FindServiceByName(name)) == nullptr) return CALLSERVICE_NOTFOUND; } @@ -578,7 +578,7 @@ static void CALLBACK CallServiceToMainAPCFunc(ULONG_PTR dwParam) MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lParam) { - if (name == NULL) + if (name == nullptr) return CALLSERVICE_NOTFOUND; // the service is looked up within the main thread, since the time it takes @@ -603,7 +603,7 @@ MIR_CORE_DLL(int) CallFunctionAsync(void(__stdcall *func)(void *), void *arg) if (GetCurrentThreadId() == mainThreadId) func(arg); else - QueueMainThread((PAPCFUNC)func, arg, 0); + QueueMainThread((PAPCFUNC)func, arg, nullptr); return 0; } @@ -691,7 +691,7 @@ MIR_CORE_DLL(void) UnregisterModule(HINSTANCE hInst) MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr) { if (pluginListAddr.getCount() == 0) - return NULL; + return nullptr; int idx; List_GetIndex((SortedList*)&pluginListAddr, codePtr, &idx); @@ -702,7 +702,7 @@ MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr) if (result < g_hInst && codePtr > g_hInst) result = g_hInst; else if (idx == 0 && codePtr < (void*)result) - result = NULL; + result = nullptr; return result; } diff --git a/src/mir_core/src/mstring.cpp b/src/mir_core/src/mstring.cpp index c5b70d6e74..78d82b1648 100644 --- a/src/mir_core/src/mstring.cpp +++ b/src/mir_core/src/mstring.cpp @@ -45,7 +45,7 @@ CNilMStringData::CNilMStringData() achNil[1] = 0;
}
-static CNilMStringData *m_nil = NULL;
+static CNilMStringData *m_nil = nullptr;
/////////////////////////////////////////////////////////////////////////////////////////
// CMBaseString
@@ -57,8 +57,8 @@ MIR_CORE_DLL(CMStringData*) mirstr_allocate(int nChars, int nCharSize) size_t nTotalSize = nDataBytes + sizeof(CMStringData);
CMStringData *pData = static_cast<CMStringData*>(malloc(nTotalSize));
- if (pData == NULL)
- return NULL;
+ if (pData == nullptr)
+ return nullptr;
pData->nRefs = 1;
pData->nAllocLength = nChars - 1;
@@ -78,8 +78,8 @@ MIR_CORE_DLL(CMStringData*) mirstr_realloc(CMStringData* pData, int nChars, int ULONG nTotalSize = nDataBytes + sizeof(CMStringData);
CMStringData *pNewData = static_cast<CMStringData*>(realloc(pData, nTotalSize));
- if (pNewData == NULL)
- return NULL;
+ if (pNewData == nullptr)
+ return nullptr;
pNewData->nAllocLength = nChars - 1;
return pNewData;
@@ -87,7 +87,7 @@ MIR_CORE_DLL(CMStringData*) mirstr_realloc(CMStringData* pData, int nChars, int MIR_CORE_DLL(CMStringData*) mirstr_getNil()
{
- if (m_nil == NULL)
+ if (m_nil == nullptr)
m_nil = new CNilMStringData();
m_nil->AddRef();
return m_nil;
diff --git a/src/mir_core/src/openurl.cpp b/src/mir_core/src/openurl.cpp index 11b761233d..6875b77bdf 100644 --- a/src/mir_core/src/openurl.cpp +++ b/src/mir_core/src/openurl.cpp @@ -58,9 +58,9 @@ static void OpenURLThread(void *arg) // check user defined browser for opening urls
ptrW tszBrowser(db_get_wsa(NULL, "Miranda", "OpenUrlBrowser"));
if (tszBrowser)
- ShellExecute(NULL, L"open", tszBrowser, tszUrl, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
+ ShellExecute(nullptr, L"open", tszBrowser, tszUrl, nullptr, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
else
- ShellExecute(NULL, L"open", tszUrl, NULL, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
+ ShellExecute(nullptr, L"open", tszUrl, nullptr, nullptr, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
delete hUrlInfo;
}
diff --git a/src/mir_core/src/path.cpp b/src/mir_core/src/path.cpp index 2faabd8219..6eca1f1329 100644 --- a/src/mir_core/src/path.cpp +++ b/src/mir_core/src/path.cpp @@ -45,7 +45,7 @@ MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut, const char *pBase if (!PathIsAbsolute(pSrc))
strncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
else {
- if (pBase == NULL)
+ if (pBase == nullptr)
pBase = szMirandaPath;
size_t cbBaseLen = strlen(pBase);
@@ -70,24 +70,24 @@ MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, const char *base) strncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
if (PathIsAbsolute(pSrc))
- return GetFullPathNameA(pSrc, MAX_PATH, pOut, NULL);
+ return GetFullPathNameA(pSrc, MAX_PATH, pOut, nullptr);
- if (base == NULL)
+ if (base == nullptr)
base = szMirandaPath;
if (pSrc[0] == '\\')
pSrc++;
mir_snprintf(buf, "%s%s", base, pSrc);
- return GetFullPathNameA(buf, _countof(buf), pOut, NULL);
+ return GetFullPathNameA(buf, _countof(buf), pOut, nullptr);
}
MIR_CORE_DLL(void) CreatePathToFile(char *szFilePath)
{
- if (szFilePath == NULL)
+ if (szFilePath == nullptr)
return;
char *pszLastBackslash = strrchr(szFilePath, '\\');
- if (pszLastBackslash == NULL)
+ if (pszLastBackslash == nullptr)
return;
*pszLastBackslash = '\0';
@@ -97,7 +97,7 @@ MIR_CORE_DLL(void) CreatePathToFile(char *szFilePath) MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir)
{
- if (szDir == NULL)
+ if (szDir == nullptr)
return 1;
char szTestDir[MAX_PATH];
@@ -108,13 +108,13 @@ MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir) return 0;
char *pszLastBackslash = strrchr(szTestDir, '\\');
- if (pszLastBackslash == NULL)
+ if (pszLastBackslash == nullptr)
return 0;
*pszLastBackslash = '\0';
CreateDirectoryTree(szTestDir);
*pszLastBackslash = '\\';
- return (CreateDirectoryA(szTestDir, NULL) == 0) ? GetLastError() : 0;
+ return (CreateDirectoryA(szTestDir, nullptr) == 0) ? GetLastError() : 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -135,7 +135,7 @@ MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR *p if (!PathIsAbsoluteW(pSrc))
wcsncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
else {
- if (pBase == NULL)
+ if (pBase == nullptr)
pBase = szMirandaPathW;
size_t cbBaseLen = wcslen(pBase);
@@ -159,25 +159,25 @@ MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR *b return mir_snwprintf(pOut, MAX_PATH, L"%s", pSrc);
if (PathIsAbsoluteW(pSrc))
- return GetFullPathName(pSrc, MAX_PATH, pOut, NULL);
+ return GetFullPathName(pSrc, MAX_PATH, pOut, nullptr);
- if (base == NULL)
+ if (base == nullptr)
base = szMirandaPathW;
if (pSrc[0] == '\\')
pSrc++;
mir_snwprintf(buf, MAX_PATH, L"%s%s", base, pSrc);
- return GetFullPathName(buf, MAX_PATH, pOut, NULL);
+ return GetFullPathName(buf, MAX_PATH, pOut, nullptr);
}
MIR_CORE_DLL(void) CreatePathToFileW(WCHAR *wszFilePath)
{
- if (wszFilePath == NULL)
+ if (wszFilePath == nullptr)
return;
WCHAR *pszLastBackslash = wcsrchr(wszFilePath, '\\');
- if (pszLastBackslash == NULL)
+ if (pszLastBackslash == nullptr)
return;
*pszLastBackslash = '\0';
@@ -187,7 +187,7 @@ MIR_CORE_DLL(void) CreatePathToFileW(WCHAR *wszFilePath) MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR *szDir)
{
- if (szDir == NULL)
+ if (szDir == nullptr)
return 1;
WCHAR szTestDir[MAX_PATH];
@@ -198,23 +198,23 @@ MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR *szDir) return 0;
WCHAR *pszLastBackslash = wcsrchr(szTestDir, '\\');
- if (pszLastBackslash == NULL)
+ if (pszLastBackslash == nullptr)
return 0;
*pszLastBackslash = '\0';
CreateDirectoryTreeW(szTestDir);
*pszLastBackslash = '\\';
- return (CreateDirectoryW(szTestDir, NULL) == 0) ? GetLastError() : 0;
+ return (CreateDirectoryW(szTestDir, nullptr) == 0) ? GetLastError() : 0;
}
int InitPathUtils(void)
{
- GetModuleFileNameA(NULL, szMirandaPath, _countof(szMirandaPath));
+ GetModuleFileNameA(nullptr, szMirandaPath, _countof(szMirandaPath));
char *p = strrchr(szMirandaPath, '\\');
if (p)
p[1] = 0;
- GetModuleFileNameW(NULL, szMirandaPathW, _countof(szMirandaPathW));
+ GetModuleFileNameW(nullptr, szMirandaPathW, _countof(szMirandaPathW));
WCHAR *tp = wcsrchr(szMirandaPathW, '\\');
if (tp)
tp[1] = 0;
diff --git a/src/mir_core/src/resizer.cpp b/src/mir_core/src/resizer.cpp index 2ad2e98bc5..faa3911749 100644 --- a/src/mir_core/src/resizer.cpp +++ b/src/mir_core/src/resizer.cpp @@ -143,8 +143,8 @@ MIR_CORE_DLL(int) Utils_ResizeDialog(HWND hwndDlg, HINSTANCE hInstance, LPCSTR l }
HWND hCtrl = GetDlgItem(hwndDlg, urc.wId);
- if (hCtrl != NULL)
- hDwp = DeferWindowPos(hDwp, hCtrl, 0, urc.rcItem.left, urc.rcItem.top, urc.rcItem.right - urc.rcItem.left, urc.rcItem.bottom - urc.rcItem.top, SWP_NOZORDER);
+ if (hCtrl != nullptr)
+ hDwp = DeferWindowPos(hDwp, hCtrl, nullptr, urc.rcItem.left, urc.rcItem.top, urc.rcItem.right - urc.rcItem.left, urc.rcItem.bottom - urc.rcItem.top, SWP_NOZORDER);
}
EndDeferWindowPos(hDwp);
return 0;
diff --git a/src/mir_core/src/sha256.cpp b/src/mir_core/src/sha256.cpp index 42b7043f50..69821977e4 100644 --- a/src/mir_core/src/sha256.cpp +++ b/src/mir_core/src/sha256.cpp @@ -197,7 +197,7 @@ MIR_CORE_DLL(void) mir_sha256_write(SHA256_CONTEXT *hd, const void *inbuf_arg, s if (hd->count) {
for (; inlen && hd->count < 64; inlen--)
hd->buf[hd->count++] = *inbuf++;
- mir_sha256_write(hd, NULL, 0);
+ mir_sha256_write(hd, nullptr, 0);
if (!inlen)
return;
}
@@ -223,7 +223,7 @@ MIR_CORE_DLL(void) mir_sha256_final(SHA256_CONTEXT *hd, BYTE hashout[MIR_SHA256_ {
UINT32 t, msb, lsb;
- mir_sha256_write(hd, NULL, 0); /* flush */;
+ mir_sha256_write(hd, nullptr, 0); /* flush */;
t = hd->nblocks;
/* multiply by 64 to make a BYTE count */
@@ -248,7 +248,7 @@ MIR_CORE_DLL(void) mir_sha256_final(SHA256_CONTEXT *hd, BYTE hashout[MIR_SHA256_ hd->buf[hd->count++] = 0x80; /* pad character */
while (hd->count < 64)
hd->buf[hd->count++] = 0;
- mir_sha256_write(hd, NULL, 0); /* flush */;
+ mir_sha256_write(hd, nullptr, 0); /* flush */;
memset(hd->buf, 0, 56); /* fill next block with zeroes */
}
/* append the 64 bit count */
diff --git a/src/mir_core/src/subclass.cpp b/src/mir_core/src/subclass.cpp index d5853e6228..c0d4fd9cdc 100644 --- a/src/mir_core/src/subclass.cpp +++ b/src/mir_core/src/subclass.cpp @@ -38,7 +38,7 @@ static LIST<MSubclassData> arSubclass(10, HandleKeySortT); static LRESULT CALLBACK MSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MSubclassData *p = arSubclass.find((MSubclassData*)&hwnd);
- if (p != NULL) {
+ if (p != nullptr) {
if (p->m_iHooks)
return p->m_hooks[p->m_iHooks-1](hwnd, uMsg, wParam, lParam);
@@ -62,7 +62,7 @@ MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc) return;
MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
- if (p == NULL) {
+ if (p == nullptr) {
p = new MSubclassData;
p->m_hWnd = hWnd;
p->m_origWndProc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)MSubclassWndProc);
@@ -89,7 +89,7 @@ MIR_CORE_DLL(void) mir_subclassWindow(HWND hWnd, WNDPROC wndProc) MIR_CORE_DLL(void) mir_subclassWindowFull(HWND hWnd, WNDPROC wndProc, WNDPROC oldWndProc)
{
MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
- if (p == NULL) {
+ if (p == nullptr) {
p = new MSubclassData;
p->m_hWnd = hWnd;
p->m_origWndProc = oldWndProc;
@@ -133,7 +133,7 @@ static WNDPROC finalizeSubclassing(HWND hWnd, MSubclassData *p) MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc)
{
MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
- if (p == NULL)
+ if (p == nullptr)
return;
for (int i = 0; i < p->m_iHooks; i++) {
@@ -152,7 +152,7 @@ MIR_CORE_DLL(void) mir_unsubclassWindow(HWND hWnd, WNDPROC wndProc) MIR_CORE_DLL(LRESULT) mir_callNextSubclass(HWND hWnd, WNDPROC wndProc, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MSubclassData *p = arSubclass.find((MSubclassData*)&hWnd);
- if (p == NULL)
+ if (p == nullptr)
return DefWindowProc(hWnd, uMsg, wParam, lParam);
for (int i = p->m_iHooks - 1; i >= 0; i--) {
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp index 94e5c853c2..97d3dcd06d 100644 --- a/src/mir_core/src/threads.cpp +++ b/src/mir_core/src/threads.cpp @@ -43,8 +43,8 @@ static int MirandaWaitForMutex(HANDLE hEvent) DWORD rc = MsgWaitForMultipleObjectsEx(1, &hEvent, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE);
if (rc == WAIT_OBJECT_0 + 1) {
MSG msg;
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
- if (msg.hwnd != NULL && IsDialogMessage(msg.hwnd, &msg)) /* Wine fix. */
+ while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
+ if (msg.hwnd != nullptr && IsDialogMessage(msg.hwnd, &msg)) /* Wine fix. */
continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
@@ -76,7 +76,7 @@ MIR_CORE_DLL(pfnExceptionFilter) GetExceptionFilter() MIR_CORE_DLL(pfnExceptionFilter) SetExceptionFilter(pfnExceptionFilter _mirandaExceptFilter)
{
pfnExceptionFilter oldOne = pMirandaExceptFilter;
- if (_mirandaExceptFilter != 0)
+ if (_mirandaExceptFilter != nullptr)
pMirandaExceptFilter = _mirandaExceptFilter;
return oldOne;
}
@@ -128,13 +128,13 @@ DWORD WINAPI forkthread_r(void *arg) MIR_CORE_DLL(HANDLE) mir_forkthread(void(__cdecl *threadcode)(void*), void *arg)
{
FORK_ARG fa;
- fa.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ fa.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
fa.threadcode = threadcode;
fa.arg = arg;
DWORD threadID;
- fa.hThread = CreateThread(NULL, 0, forkthread_r, &fa, 0, &threadID);
- if (fa.hThread != NULL)
+ fa.hThread = CreateThread(nullptr, 0, forkthread_r, &fa, 0, &threadID);
+ if (fa.hThread != nullptr)
WaitForSingleObject(fa.hEvent, INFINITE);
CloseHandle(fa.hEvent);
@@ -167,17 +167,17 @@ DWORD WINAPI forkthreadex_r(void * arg) MIR_CORE_DLL(HANDLE) mir_forkthreadex(pThreadFuncEx aFunc, void* arg, unsigned *pThreadID)
{
- struct FORK_ARG fa = { 0 };
+ struct FORK_ARG fa = {};
fa.threadcodeex = aFunc;
fa.arg = arg;
- fa.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ fa.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
DWORD threadID = 0;
- HANDLE hThread = CreateThread(NULL, 0, forkthreadex_r, &fa, 0, &threadID);
- if (hThread != NULL)
+ HANDLE hThread = CreateThread(nullptr, 0, forkthreadex_r, &fa, 0, &threadID);
+ if (hThread != nullptr)
WaitForSingleObject(fa.hEvent, INFINITE);
- if (pThreadID != NULL)
+ if (pThreadID != nullptr)
*pThreadID = threadID;
CloseHandle(fa.hEvent);
@@ -186,18 +186,18 @@ MIR_CORE_DLL(HANDLE) mir_forkthreadex(pThreadFuncEx aFunc, void* arg, unsigned * MIR_CORE_DLL(HANDLE) mir_forkthreadowner(pThreadFuncOwner aFunc, void *owner, void *arg, unsigned *pThreadID)
{
- struct FORK_ARG fa = { 0 };
+ struct FORK_ARG fa = {};
fa.threadcodeex = (pThreadFuncEx)aFunc;
fa.arg = arg;
fa.owner = owner;
- fa.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ fa.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
DWORD threadID = 0;
- HANDLE hThread = CreateThread(NULL, 0, forkthreadex_r, &fa, 0, &threadID);
- if (hThread != NULL)
+ HANDLE hThread = CreateThread(nullptr, 0, forkthreadex_r, &fa, 0, &threadID);
+ if (hThread != nullptr)
WaitForSingleObject(fa.hEvent, INFINITE);
- if (pThreadID != NULL)
+ if (pThreadID != nullptr)
*pThreadID = threadID;
CloseHandle(fa.hEvent);
@@ -208,7 +208,7 @@ MIR_CORE_DLL(HANDLE) mir_forkthreadowner(pThreadFuncOwner aFunc, void *owner, vo MIR_CORE_DLL(void) KillObjectThreads(void* owner)
{
- if (owner == NULL)
+ if (owner == nullptr)
return;
WaitForSingleObject(hStackMutex, INFINITE);
@@ -233,7 +233,7 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner) if (p->pObject == owner) {
char szModuleName[MAX_PATH];
GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(0, "Killing object thread %s:%p", szModuleName, p->dwThreadId);
+ Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, p->dwThreadId);
TerminateThread(p->hThread, 9999);
CloseHandle(p->hThread);
threads.remove(j);
@@ -254,7 +254,7 @@ static void CALLBACK KillAllThreads(HWND, UINT, UINT_PTR, DWORD) THREAD_WAIT_ENTRY *p = threads[j];
char szModuleName[MAX_PATH];
GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(0, "Killing thread %s:%p (%p)", szModuleName, p->dwThreadId, p->pEntryPoint);
+ Netlib_Logf(nullptr, "Killing thread %s:%p (%p)", szModuleName, p->dwThreadId, p->pEntryPoint);
TerminateThread(p->hThread, 9999);
CloseHandle(p->hThread);
mir_free(p);
@@ -277,7 +277,7 @@ MIR_CORE_DLL(void) Thread_Wait(void) }
// give all unclosed threads 5 seconds to close
- SetTimer(NULL, 0, 5000, KillAllThreads);
+ SetTimer(nullptr, 0, 5000, KillAllThreads);
// wait til the thread list is empty
MirandaWaitForMutex(hThreadQueueEmpty);
@@ -291,20 +291,20 @@ typedef LONG (WINAPI *pNtQIT)(HANDLE, LONG, PVOID, ULONG, PULONG); static void* GetCurrentThreadEntryPoint()
{
pNtQIT NtQueryInformationThread = (pNtQIT)GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtQueryInformationThread");
- if (NtQueryInformationThread == NULL)
- return 0;
+ if (NtQueryInformationThread == nullptr)
+ return nullptr;
HANDLE hDupHandle, hCurrentProcess = GetCurrentProcess();
if (!DuplicateHandle(hCurrentProcess, GetCurrentThread(), hCurrentProcess, &hDupHandle, THREAD_QUERY_INFORMATION, FALSE, 0)) {
SetLastError(ERROR_ACCESS_DENIED);
- return NULL;
+ return nullptr;
}
DWORD_PTR dwStartAddress;
- LONG ntStatus = NtQueryInformationThread(hDupHandle, ThreadQuerySetWin32StartAddress, &dwStartAddress, sizeof(DWORD_PTR), NULL);
+ LONG ntStatus = NtQueryInformationThread(hDupHandle, ThreadQuerySetWin32StartAddress, &dwStartAddress, sizeof(DWORD_PTR), nullptr);
CloseHandle(hDupHandle);
- return (ntStatus != ERROR_SUCCESS) ? NULL : (void*)dwStartAddress;
+ return (ntStatus != ERROR_SUCCESS) ? nullptr : (void*)dwStartAddress;
}
MIR_CORE_DLL(INT_PTR) Thread_Push(HINSTANCE hInst, void* pOwner)
@@ -319,7 +319,7 @@ MIR_CORE_DLL(INT_PTR) Thread_Push(HINSTANCE hInst, void* pOwner) if (pluginListAddr.getIndex(hInst) != -1)
p->hOwner = hInst;
else
- p->hOwner = GetInstByAddress((hInst != NULL) ? (PVOID)hInst : GetCurrentThreadEntryPoint());
+ p->hOwner = GetInstByAddress((hInst != nullptr) ? (PVOID)hInst : GetCurrentThreadEntryPoint());
p->pEntryPoint = hInst;
threads.insert(p);
diff --git a/src/mir_core/src/timezones.cpp b/src/mir_core/src/timezones.cpp index a973d7fbd0..66f912db8a 100644 --- a/src/mir_core/src/timezones.cpp +++ b/src/mir_core/src/timezones.cpp @@ -84,7 +84,7 @@ mir_time FileTimeToUnixTime(LPFILETIME pft) void FormatTime(const SYSTEMTIME *st, const wchar_t *szFormat, wchar_t *szDest, size_t cbDest)
{
- if (szDest == NULL || cbDest == 0) return;
+ if (szDest == nullptr || cbDest == 0) return;
CMStringW tszTemp;
@@ -130,11 +130,11 @@ void FormatTime(const SYSTEMTIME *st, const wchar_t *szFormat, wchar_t *szDest, if (iso)
tszTemp.AppendFormat(L"%d-%02d-%02dT%02d:%02d:%02dZ", st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond);
else if (date) {
- GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, _countof(dateTimeStr));
+ GetDateFormat(LOCALE_USER_DEFAULT, fmt, st, nullptr, dateTimeStr, _countof(dateTimeStr));
tszTemp.Append(dateTimeStr);
}
else {
- GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, NULL, dateTimeStr, _countof(dateTimeStr));
+ GetTimeFormat(LOCALE_USER_DEFAULT, fmt, st, nullptr, dateTimeStr, _countof(dateTimeStr));
tszTemp.Append(dateTimeStr);
}
}
@@ -144,7 +144,7 @@ void FormatTime(const SYSTEMTIME *st, const wchar_t *szFormat, wchar_t *szDest, MIR_CORE_DLL(int) TimeZone_GetTimeZoneTime(HANDLE hTZ, SYSTEMTIME *st)
{
- if (st == NULL) return 1;
+ if (st == nullptr) return 1;
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
if (tz == UTC_TIME_HANDLE)
@@ -163,7 +163,7 @@ MIR_CORE_DLL(int) TimeZone_GetTimeZoneTime(HANDLE hTZ, SYSTEMTIME *st) MIR_CORE_DLL(LPCTSTR) TimeZone_GetName(HANDLE hTZ)
{
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
- if (tz == NULL)
+ if (tz == nullptr)
return myInfo.myTZ.tszName;
else if (tz == UTC_TIME_HANDLE)
return L"UTC";
@@ -208,38 +208,38 @@ static bool IsSameTime(MIM_TIMEZONE *tz) return true;
TimeZone_GetTimeZoneTime(tz, &stl);
- TimeZone_GetTimeZoneTime(NULL, &st);
+ TimeZone_GetTimeZoneTime(nullptr, &st);
return st.wHour == stl.wHour && st.wMinute == stl.wMinute;
}
MIR_CORE_DLL(HANDLE) TimeZone_CreateByName(LPCTSTR tszName, DWORD dwFlags)
{
- if (tszName == NULL)
- return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
+ if (tszName == nullptr)
+ return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? nullptr : &myInfo.myTZ;
if (mir_wstrcmp(myInfo.myTZ.tszName, tszName) == 0)
- return (dwFlags & TZF_DIFONLY) ? NULL : &myInfo.myTZ;
+ return (dwFlags & TZF_DIFONLY) ? nullptr : &myInfo.myTZ;
MIM_TIMEZONE tzsearch;
tzsearch.hash = mir_hashstrT(tszName);
MIM_TIMEZONE *tz = g_timezones.find(&tzsearch);
- if (tz == NULL)
- return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
+ if (tz == nullptr)
+ return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? nullptr : &myInfo.myTZ;
if (dwFlags & TZF_DIFONLY)
- return IsSameTime(tz) ? NULL : tz;
+ return IsSameTime(tz) ? nullptr : tz;
return tz;
}
MIR_CORE_DLL(HANDLE) TimeZone_CreateByContact(MCONTACT hContact, LPCSTR szModule, DWORD dwFlags)
{
- if (hContact == NULL && szModule == NULL)
- return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
+ if (hContact == NULL && szModule == nullptr)
+ return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? nullptr : &myInfo.myTZ;
- if (szModule == NULL) szModule = "UserInfo";
+ if (szModule == nullptr) szModule = "UserInfo";
DBVARIANT dbv;
if (!db_get_ws(hContact, szModule, "TzName", &dbv)) {
@@ -263,7 +263,7 @@ MIR_CORE_DLL(HANDLE) TimeZone_CreateByContact(MCONTACT hContact, LPCSTR szModule MIM_TIMEZONE tzsearch;
tzsearch.tzi.Bias = timezone * 30;
if (myInfo.myTZ.tzi.Bias == tzsearch.tzi.Bias) {
- if (dwFlags & TZF_DIFONLY) return NULL;
+ if (dwFlags & TZF_DIFONLY) return nullptr;
return &myInfo.myTZ;
}
@@ -281,15 +281,15 @@ MIR_CORE_DLL(HANDLE) TimeZone_CreateByContact(MCONTACT hContact, LPCSTR szModule if (i >= 0) {
MIM_TIMEZONE *tz = g_timezonesBias[i];
- return ((dwFlags & TZF_DIFONLY) && IsSameTime(tz)) ? NULL : tz;
+ return ((dwFlags & TZF_DIFONLY) && IsSameTime(tz)) ? nullptr : tz;
}
}
- return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
+ return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? nullptr : &myInfo.myTZ;
}
MIR_CORE_DLL(void) TimeZone_StoreByContact(MCONTACT hContact, LPCSTR szModule, HANDLE hTZ)
{
- if (szModule == NULL) szModule = "UserInfo";
+ if (szModule == nullptr) szModule = "UserInfo";
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
if (tz) {
@@ -305,7 +305,7 @@ MIR_CORE_DLL(void) TimeZone_StoreByContact(MCONTACT hContact, LPCSTR szModule, H MIR_CORE_DLL(int) TimeZone_PrintDateTime(HANDLE hTZ, LPCTSTR szFormat, LPTSTR szDest, size_t cbDest, DWORD dwFlags)
{
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
- if (tz == NULL && (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)))
+ if (tz == nullptr && (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)))
return 1;
SYSTEMTIME st;
@@ -319,10 +319,10 @@ MIR_CORE_DLL(int) TimeZone_PrintDateTime(HANDLE hTZ, LPCTSTR szFormat, LPTSTR sz MIR_CORE_DLL(int) TimeZone_PrintTimeStamp(HANDLE hTZ, mir_time ts, LPCTSTR szFormat, LPTSTR szDest, size_t cbDest, DWORD dwFlags)
{
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
- if (tz == NULL && (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)))
+ if (tz == nullptr && (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)))
return 1;
- if (tz == NULL)
+ if (tz == nullptr)
tz = &myInfo.myTZ;
FILETIME ft;
@@ -351,7 +351,7 @@ MIR_CORE_DLL(LPTIME_ZONE_INFORMATION) TimeZone_GetInfo(HANDLE hTZ) MIR_CORE_DLL(mir_time) TimeZone_UtcToLocal(HANDLE hTZ, mir_time ts)
{
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ;
- if (tz == NULL)
+ if (tz == nullptr)
tz = &myInfo.myTZ;
if (tz == UTC_TIME_HANDLE)
@@ -375,8 +375,8 @@ static const ListMessages cbMessages = { CB_ADDSTRING, CB_GETCURSEL, CB_SETCURSE static const ListMessages* GetListMessages(HWND hWnd, DWORD dwFlags)
{
- if (hWnd == NULL)
- return NULL;
+ if (hWnd == nullptr)
+ return nullptr;
if (!(dwFlags & (TZF_PLF_CB | TZF_PLF_LB))) {
wchar_t tszClassName[128];
@@ -391,7 +391,7 @@ static const ListMessages* GetListMessages(HWND hWnd, DWORD dwFlags) else if (dwFlags & TZF_PLF_LB)
return &lbMessages;
else
- return NULL;
+ return nullptr;
}
///////////////////////////////////////////////////////////////////////////////
@@ -399,10 +399,10 @@ static const ListMessages* GetListMessages(HWND hWnd, DWORD dwFlags) MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags)
{
const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
- if (lstMsg == NULL)
+ if (lstMsg == nullptr)
return -1;
- if (szModule == NULL) szModule = "UserInfo";
+ if (szModule == nullptr) szModule = "UserInfo";
int iSelection = 0;
ptrW tszName(db_get_wsa(hContact, szModule, "TzName"));
@@ -435,7 +435,7 @@ MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HW MIR_CORE_DLL(int) TimeZone_PrepareList(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags)
{
const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
- if (lstMsg == NULL)
+ if (lstMsg == nullptr)
return 0;
SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)TranslateT("<unspecified>"));
@@ -452,17 +452,17 @@ MIR_CORE_DLL(int) TimeZone_PrepareList(MCONTACT hContact, LPCSTR szModule, HWND MIR_CORE_DLL(void) TimeZone_StoreListResult(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags)
{
- if (szModule == NULL) szModule = "UserInfo";
+ if (szModule == nullptr) szModule = "UserInfo";
const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
if (lstMsg) {
LRESULT offset = SendMessage(hWnd, lstMsg->getSel, 0, 0);
if (offset > 0) {
MIM_TIMEZONE *tz = (MIM_TIMEZONE*)SendMessage(hWnd, lstMsg->getData, offset, 0);
- if ((INT_PTR)tz != CB_ERR && tz != NULL)
+ if ((INT_PTR)tz != CB_ERR && tz != nullptr)
TimeZone_StoreByContact(hContact, szModule, tz);
}
- else TimeZone_StoreByContact(hContact, szModule, NULL);
+ else TimeZone_StoreByContact(hContact, szModule, nullptr);
}
}
@@ -470,20 +470,20 @@ MIR_CORE_DLL(void) TimeZone_StoreListResult(MCONTACT hContact, LPCSTR szModule, MIR_CORE_DLL(DWORD) TimeZone_ToLocal(DWORD timeVal)
{
- return TimeZone_UtcToLocal(NULL, (mir_time)timeVal);
+ return TimeZone_UtcToLocal(nullptr, (mir_time)timeVal);
}
MIR_CORE_DLL(char*) TimeZone_ToString(mir_time timeVal, const char *szFormat, char *szDest, size_t cchDest)
{
wchar_t *szTemp = (wchar_t*)alloca(cchDest*sizeof(wchar_t));
- TimeZone_PrintTimeStamp(NULL, timeVal, _A2T(szFormat), szTemp, cchDest, 0);
- WideCharToMultiByte(CP_ACP, 0, szTemp, -1, szDest, (int)cchDest, NULL, NULL);
+ TimeZone_PrintTimeStamp(nullptr, timeVal, _A2T(szFormat), szTemp, cchDest, 0);
+ WideCharToMultiByte(CP_ACP, 0, szTemp, -1, szDest, (int)cchDest, nullptr, nullptr);
return szDest;
}
MIR_CORE_DLL(wchar_t*) TimeZone_ToStringW(mir_time timeVal, const wchar_t *wszFormat, wchar_t *wszDest, size_t cchDest)
{
- TimeZone_PrintTimeStamp(NULL, timeVal, wszFormat, wszDest, cchDest, 0);
+ TimeZone_PrintTimeStamp(nullptr, timeVal, wszFormat, wszDest, cchDest, 0);
return wszDest;
}
@@ -492,14 +492,14 @@ MIR_CORE_DLL(wchar_t*) TimeZone_ToStringW(mir_time timeVal, const wchar_t *wszFo void GetLocalizedString(HKEY hSubKey, const wchar_t *szName, wchar_t *szBuf, DWORD cbLen)
{
DWORD dwLength = cbLen * sizeof(wchar_t);
- RegQueryValueEx(hSubKey, szName, NULL, NULL, (unsigned char *)szBuf, &dwLength);
+ RegQueryValueEx(hSubKey, szName, nullptr, nullptr, (unsigned char *)szBuf, &dwLength);
szBuf[min(dwLength / sizeof(wchar_t), cbLen - 1)] = 0;
}
void RecalculateTime(void)
{
GetTimeZoneInformation(&myInfo.myTZ.tzi);
- myInfo.timestamp = time(NULL);
+ myInfo.timestamp = time(nullptr);
myInfo.myTZ.offset = INT_MIN;
bool found = false;
@@ -545,12 +545,12 @@ void InitTimeZones(void) wchar_t tszName[MIM_TZ_NAMELEN];
DWORD dwSize = _countof(tszName);
- while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx(hKey, dwIndex++, tszName, &dwSize, NULL, NULL, 0, NULL)) {
+ while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx(hKey, dwIndex++, tszName, &dwSize, nullptr, nullptr, nullptr, nullptr)) {
if (ERROR_SUCCESS == RegOpenKeyEx(hKey, tszName, 0, KEY_QUERY_VALUE, &hSubKey)) {
dwSize = sizeof(tszName);
DWORD dwLength = sizeof(tzi);
- if (ERROR_SUCCESS != RegQueryValueEx(hSubKey, L"TZI", NULL, NULL, (unsigned char *)&tzi, &dwLength))
+ if (ERROR_SUCCESS != RegQueryValueEx(hSubKey, L"TZI", nullptr, nullptr, (unsigned char *)&tzi, &dwLength))
continue;
MIM_TIMEZONE *tz = new MIM_TIMEZONE;
diff --git a/src/mir_core/src/utf.cpp b/src/mir_core/src/utf.cpp index 06b815ac48..f0aad890e1 100644 --- a/src/mir_core/src/utf.cpp +++ b/src/mir_core/src/utf.cpp @@ -90,7 +90,7 @@ static int Ucs2toUtf8Len(const wchar_t *src, unsigned int srclen) MIR_CORE_DLL(int) Ucs2toUtf8Len(const wchar_t *src)
{
- if (src == 0)
+ if (src == nullptr)
return 0;
return Ucs2toUtf8Len(src, (int)wcslen(src));
@@ -241,16 +241,16 @@ MIR_CORE_DLL(int) Utf8toUcs2(const char *src, size_t srclen, wchar_t *dst, size_ MIR_CORE_DLL(char*) Utf8DecodeCP(char *str, int codepage, wchar_t **ucs2)
{
bool needs_free = false;
- wchar_t* tempBuf = NULL;
+ wchar_t* tempBuf = nullptr;
if (ucs2)
- *ucs2 = NULL;
+ *ucs2 = nullptr;
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
size_t len = strlen(str);
if (len < 2) {
- if (ucs2 != NULL) {
+ if (ucs2 != nullptr) {
*ucs2 = tempBuf = (wchar_t*)mir_alloc((len + 1) * sizeof(wchar_t));
MultiByteToWideChar(codepage, 0, str, (int)len, tempBuf, (int)len);
tempBuf[len] = 0;
@@ -260,28 +260,28 @@ MIR_CORE_DLL(char*) Utf8DecodeCP(char *str, int codepage, wchar_t **ucs2) int destlen = Utf8toUcs2Len(str, len);
if (destlen < 0)
- return NULL;
+ return nullptr;
- if (ucs2 == NULL) {
+ if (ucs2 == nullptr) {
__try {
tempBuf = (wchar_t*)alloca((destlen + 1) * sizeof(wchar_t));
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
- tempBuf = NULL;
+ tempBuf = nullptr;
needs_free = true;
}
}
- if (tempBuf == NULL) {
+ if (tempBuf == nullptr) {
tempBuf = (wchar_t*)mir_alloc((destlen + 1) * sizeof(wchar_t));
- if (tempBuf == NULL)
- return NULL;
+ if (tempBuf == nullptr)
+ return nullptr;
}
Utf8toUcs2(str, len, tempBuf, destlen);
tempBuf[destlen] = 0;
- WideCharToMultiByte(codepage, 0, tempBuf, -1, str, (int)len + 1, "?", NULL);
+ WideCharToMultiByte(codepage, 0, tempBuf, -1, str, (int)len + 1, "?", nullptr);
if (ucs2)
*ucs2 = tempBuf;
@@ -298,18 +298,18 @@ MIR_CORE_DLL(char*) Utf8Decode(char *str, wchar_t **ucs2) MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
size_t len = strlen(str);
int destlen = Utf8toUcs2Len(str, len);
if (destlen < 0)
- return NULL;
+ return nullptr;
wchar_t* ucs2 = (wchar_t*)mir_alloc((destlen + 1) * sizeof(wchar_t));
- if (ucs2 == NULL)
- return NULL;
+ if (ucs2 == nullptr)
+ return nullptr;
if (Utf8toUcs2(str, len, ucs2, destlen) >= 0) {
ucs2[destlen] = 0;
@@ -318,7 +318,7 @@ MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char *str) mir_free(ucs2);
- return NULL;
+ return nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -328,11 +328,11 @@ MIR_CORE_DLL(char*) Utf8EncodeCP(const char* src, int codepage) {
int len;
bool needs_free = false;
- char* result = NULL;
+ char* result = nullptr;
wchar_t* tempBuf;
- if (src == NULL)
- return NULL;
+ if (src == nullptr)
+ return nullptr;
len = (int)strlen(src);
@@ -342,7 +342,7 @@ MIR_CORE_DLL(char*) Utf8EncodeCP(const char* src, int codepage) __except (EXCEPTION_EXECUTE_HANDLER)
{
tempBuf = (wchar_t*)mir_alloc((len + 1) * sizeof(wchar_t));
- if (tempBuf == NULL) return NULL;
+ if (tempBuf == nullptr) return nullptr;
needs_free = true;
}
@@ -373,17 +373,17 @@ MIR_CORE_DLL(char*) Utf8Encode(const char* src) MIR_CORE_DLL(char*) Utf8EncodeW(const wchar_t* src)
{
- if (src == NULL)
- return NULL;
+ if (src == nullptr)
+ return nullptr;
int len = (int)wcslen(src);
int destlen = Ucs2toUtf8Len(src, len);
- if (destlen < 0) return NULL;
+ if (destlen < 0) return nullptr;
char* result = (char*)mir_alloc(destlen + 1);
- if (result == NULL)
- return NULL;
+ if (result == nullptr)
+ return nullptr;
Ucs2toUtf8(src, len, result, destlen);
result[destlen] = 0;
diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp index 8a9f3366c0..94ff07c7d1 100644 --- a/src/mir_core/src/utils.cpp +++ b/src/mir_core/src/utils.cpp @@ -26,24 +26,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. MIR_CORE_DLL(char*) replaceStr(char* &dest, const char *src)
{
- if (dest != NULL)
+ if (dest != nullptr)
mir_free(dest);
- return dest = (src != NULL) ? mir_strdup(src) : NULL;
+ return dest = (src != nullptr) ? mir_strdup(src) : nullptr;
}
MIR_CORE_DLL(WCHAR*) replaceStrW(WCHAR* &dest, const WCHAR *src)
{
- if (dest != NULL)
+ if (dest != nullptr)
mir_free(dest);
- return dest = (src != NULL) ? mir_wstrdup(src) : NULL;
+ return dest = (src != nullptr) ? mir_wstrdup(src) : nullptr;
}
MIR_CORE_DLL(char*) rtrim(char *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
char* p = strchr(str, 0);
while (--p >= str) {
@@ -59,8 +59,8 @@ MIR_CORE_DLL(char*) rtrim(char *str) MIR_CORE_DLL(WCHAR*) rtrimw(WCHAR *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
WCHAR *p = wcschr(str, 0);
while (--p >= str) {
@@ -76,8 +76,8 @@ MIR_CORE_DLL(WCHAR*) rtrimw(WCHAR *str) MIR_CORE_DLL(char*) ltrim(char *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
char* p = str;
for (;;) {
@@ -93,8 +93,8 @@ MIR_CORE_DLL(char*) ltrim(char *str) MIR_CORE_DLL(WCHAR*) ltrimw(WCHAR *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
WCHAR *p = str;
for (;;) {
@@ -110,8 +110,8 @@ MIR_CORE_DLL(WCHAR*) ltrimw(WCHAR *str) MIR_CORE_DLL(char*) ltrimp(char *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
char *p = str;
for (;;) {
@@ -126,8 +126,8 @@ MIR_CORE_DLL(char*) ltrimp(char *str) MIR_CORE_DLL(WCHAR*) ltrimpw(WCHAR *str)
{
- if (str == NULL)
- return NULL;
+ if (str == nullptr)
+ return nullptr;
WCHAR *p = str;
for (;;) {
@@ -166,10 +166,10 @@ MIR_CORE_DLL(wchar_t*) strdelw(wchar_t *str, size_t len) MIR_CORE_DLL(int) wildcmp(const char *name, const char *mask)
{
- if (name == NULL || mask == NULL)
+ if (name == nullptr || mask == nullptr)
return false;
- const char *last = '\0';
+ const char *last = nullptr;
for (;; mask++, name++) {
if (*mask != '?' && *mask != *name) break;
if (*name == '\0') return ((BOOL)!*mask);
@@ -187,10 +187,10 @@ MIR_CORE_DLL(int) wildcmp(const char *name, const char *mask) MIR_CORE_DLL(int) wildcmpw(const WCHAR *name, const WCHAR *mask)
{
- if (name == NULL || mask == NULL)
+ if (name == nullptr || mask == nullptr)
return false;
- const WCHAR* last = '\0';
+ const WCHAR* last = nullptr;
for (;; mask++, name++) {
if (*mask != '?' && *mask != *name) break;
if (*name == '\0') return ((BOOL)!*mask);
@@ -210,10 +210,10 @@ MIR_CORE_DLL(int) wildcmpw(const WCHAR *name, const WCHAR *mask) MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask)
{
- if (name == NULL || mask == NULL)
+ if (name == nullptr || mask == nullptr)
return false;
- const char *last = NULL;
+ const char *last = nullptr;
for (;; mask++, name++) {
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
if (*name == '\0') return ((BOOL)!*mask);
@@ -231,10 +231,10 @@ MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask) MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask)
{
- if (name == NULL || mask == NULL)
+ if (name == nullptr || mask == nullptr)
return false;
- const WCHAR* last = NULL;
+ const WCHAR* last = nullptr;
for (;; mask++, name++) {
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
if (*name == '\0') return ((BOOL)!*mask);
@@ -295,7 +295,7 @@ static int hex2dec(int iHex) MIR_CORE_DLL(bool) hex2bin(const char *pSrc, void *pData, size_t len)
{
- if (pSrc == NULL || pData == NULL || len == 0)
+ if (pSrc == nullptr || pData == nullptr || len == 0)
return false;
size_t bufLen = strlen(pSrc)/2;
@@ -314,7 +314,7 @@ MIR_CORE_DLL(bool) hex2bin(const char *pSrc, void *pData, size_t len) MIR_CORE_DLL(bool) hex2binW(const wchar_t *pSrc, void *pData, size_t len)
{
- if (pSrc == NULL || pData == NULL || len == 0)
+ if (pSrc == nullptr || pData == nullptr || len == 0)
return false;
size_t bufLen = wcslen(pSrc)/2;
@@ -348,10 +348,10 @@ MIR_CORE_DLL(size_t) mir_wstrlen(const wchar_t *p) MIR_CORE_DLL(char*) mir_strcpy(char *dest, const char *src)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL) {
+ if (src == nullptr) {
*dest = 0;
return dest;
}
@@ -361,10 +361,10 @@ MIR_CORE_DLL(char*) mir_strcpy(char *dest, const char *src) MIR_CORE_DLL(wchar_t*) mir_wstrcpy(wchar_t *dest, const wchar_t *src)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL) {
+ if (src == nullptr) {
*dest = 0;
return dest;
}
@@ -374,10 +374,10 @@ MIR_CORE_DLL(wchar_t*) mir_wstrcpy(wchar_t *dest, const wchar_t *src) MIR_CORE_DLL(char*) mir_strncpy(char *dest, const char *src, size_t len)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL)
+ if (src == nullptr)
*dest = 0;
else
strncpy_s(dest, len, src, _TRUNCATE);
@@ -386,10 +386,10 @@ MIR_CORE_DLL(char*) mir_strncpy(char *dest, const char *src, size_t len) MIR_CORE_DLL(wchar_t*) mir_wstrncpy(wchar_t *dest, const wchar_t *src, size_t len)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL)
+ if (src == nullptr)
*dest = 0;
else
wcsncpy_s(dest, len, src, _TRUNCATE);
@@ -398,10 +398,10 @@ MIR_CORE_DLL(wchar_t*) mir_wstrncpy(wchar_t *dest, const wchar_t *src, size_t le MIR_CORE_DLL(char*) mir_strcat(char *dest, const char *src)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL) {
+ if (src == nullptr) {
*dest = 0;
return dest;
}
@@ -411,10 +411,10 @@ MIR_CORE_DLL(char*) mir_strcat(char *dest, const char *src) MIR_CORE_DLL(wchar_t*) mir_wstrcat(wchar_t *dest, const wchar_t *src)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL) {
+ if (src == nullptr) {
*dest = 0;
return dest;
}
@@ -424,10 +424,10 @@ MIR_CORE_DLL(wchar_t*) mir_wstrcat(wchar_t *dest, const wchar_t *src) MIR_CORE_DLL(char*) mir_strncat(char *dest, const char *src, size_t len)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL)
+ if (src == nullptr)
*dest = 0;
else
strncat_s(dest, len, src, _TRUNCATE);
@@ -436,10 +436,10 @@ MIR_CORE_DLL(char*) mir_strncat(char *dest, const char *src, size_t len) MIR_CORE_DLL(wchar_t*) mir_wstrncat(wchar_t *dest, const wchar_t *src, size_t len)
{
- if (dest == NULL)
- return NULL;
+ if (dest == nullptr)
+ return nullptr;
- if (src == NULL)
+ if (src == nullptr)
*dest = 0;
else
wcsncat_s(dest, len, src, _TRUNCATE);
@@ -448,72 +448,72 @@ MIR_CORE_DLL(wchar_t*) mir_wstrncat(wchar_t *dest, const wchar_t *src, size_t le MIR_CORE_DLL(int) mir_strcmp(const char *p1, const char *p2)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return strcmp(p1, p2);
}
MIR_CORE_DLL(int) mir_wstrcmp(const wchar_t *p1, const wchar_t *p2)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return wcscmp(p1, p2);
}
MIR_CORE_DLL(int) mir_strcmpi(const char *p1, const char *p2)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return stricmp(p1, p2);
}
MIR_CORE_DLL(int) mir_wstrcmpi(const wchar_t *p1, const wchar_t *p2)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return wcsicmp(p1, p2);
}
MIR_CORE_DLL(int) mir_strncmp(const char *p1, const char *p2, size_t n)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return strncmp(p1, p2, n);
}
MIR_CORE_DLL(int) mir_wstrncmp(const wchar_t *p1, const wchar_t *p2, size_t n)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return wcsncmp(p1, p2, n);
}
MIR_CORE_DLL(int) mir_strncmpi(const char *p1, const char *p2, size_t n)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return strnicmp(p1, p2, n);
}
MIR_CORE_DLL(int) mir_wstrncmpi(const wchar_t *p1, const wchar_t *p2, size_t n)
{
- if (p1 == NULL)
- return (p2 == NULL) ? 0 : -1;
- if (p2 == NULL)
+ if (p1 == nullptr)
+ return (p2 == nullptr) ? 0 : -1;
+ if (p2 == nullptr)
return 1;
return wcsnicmp(p1, p2, n);
}
@@ -527,10 +527,10 @@ MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen) if (pszDest == nullptr || cbLen == 0)
return;
- if (pfnRtlGenRandom != NULL)
+ if (pfnRtlGenRandom != nullptr)
pfnRtlGenRandom(pszDest, (ULONG)cbLen);
else {
- srand(time(NULL));
+ srand(time(nullptr));
BYTE *p = (BYTE*)pszDest;
for (size_t i = 0; i < cbLen; i++)
p[i] = rand() & 0xFF;
diff --git a/src/mir_core/src/windowlist.cpp b/src/mir_core/src/windowlist.cpp index 7af092dc1d..a945710dd5 100644 --- a/src/mir_core/src/windowlist.cpp +++ b/src/mir_core/src/windowlist.cpp @@ -55,7 +55,7 @@ MIR_CORE_DLL(void) WindowList_Destroy(MWindowList &hList) MIR_CORE_DLL(int) WindowList_Add(MWindowList hList, HWND hwnd, MCONTACT hContact)
{
- if (hList == NULL)
+ if (hList == nullptr)
return 1;
hList->insert(new TWindowListItem(hContact, hwnd));
@@ -64,7 +64,7 @@ MIR_CORE_DLL(int) WindowList_Add(MWindowList hList, HWND hwnd, MCONTACT hContact MIR_CORE_DLL(int) WindowList_Remove(MWindowList hList, HWND hwnd)
{
- if (hList == NULL) return 1;
+ if (hList == nullptr) return 1;
for (int i = 0; i < hList->getCount(); i++) {
if ((*hList)[i].hWnd == hwnd) {
@@ -77,16 +77,16 @@ MIR_CORE_DLL(int) WindowList_Remove(MWindowList hList, HWND hwnd) MIR_CORE_DLL(HWND) WindowList_Find(MWindowList hList, MCONTACT hContact)
{
- if (hList == NULL)
- return NULL;
+ if (hList == nullptr)
+ return nullptr;
TWindowListItem *p = hList->find((TWindowListItem*)&hContact);
- return (p == NULL) ? NULL : p->hWnd;
+ return (p == nullptr) ? nullptr : p->hWnd;
}
MIR_CORE_DLL(int) WindowList_Broadcast(MWindowList hList, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (hList == NULL)
+ if (hList == nullptr)
return NULL;
for (int i = hList->getCount()-1; i >= 0; i--)
@@ -96,7 +96,7 @@ MIR_CORE_DLL(int) WindowList_Broadcast(MWindowList hList, UINT message, WPARAM w MIR_CORE_DLL(int) WindowList_BroadcastAsync(MWindowList hList, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (hList == NULL)
+ if (hList == nullptr)
return NULL;
for (int i = hList->getCount()-1; i >= 0; i--)
diff --git a/src/mir_core/src/winutil.cpp b/src/mir_core/src/winutil.cpp index bc8e20a2a7..0397aa04ff 100644 --- a/src/mir_core/src/winutil.cpp +++ b/src/mir_core/src/winutil.cpp @@ -91,7 +91,7 @@ EXTERN_C MIR_CORE_DLL(int) Utils_RestoreWindowPosition(HWND hwnd, MCONTACT hCont MIR_CORE_DLL(int) Utils_AssertInsideScreen(RECT *rc)
{
- if (rc == NULL)
+ if (rc == nullptr)
return -1;
RECT rcScreen;
diff --git a/src/mir_core/src/winver.cpp b/src/mir_core/src/winver.cpp index 09edd739ba..15b70343a3 100644 --- a/src/mir_core/src/winver.cpp +++ b/src/mir_core/src/winver.cpp @@ -90,7 +90,7 @@ MIR_CORE_DLL(BOOL) IsFullScreen() MIR_CORE_DLL(BOOL) IsWorkstationLocked(void)
{
HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
- if (hDesk == NULL)
+ if (hDesk == nullptr)
return true;
wchar_t tszName[100];
@@ -200,7 +200,7 @@ typedef LPCSTR(WINAPI *WGV)(void); MIR_CORE_DLL(BOOL) GetOSDisplayString(wchar_t *buf, size_t bufSize)
{
- if (buf == NULL || bufSize == 0)
+ if (buf == nullptr || bufSize == 0)
return 0;
buf[0] = 0;
@@ -263,7 +263,7 @@ MIR_CORE_DLL(BOOL) GetOSDisplayString(wchar_t *buf, size_t bufSize) DWORD dwType = 0;
HMODULE hKernel = GetModuleHandle(L"kernel32.dll");
PGPI pGPI = (PGPI)GetProcAddress(hKernel, "GetProductInfo");
- if (pGPI != NULL)
+ if (pGPI != nullptr)
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
switch (dwType) {
|