From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- plugins/ShellExt/src/main.cpp | 22 +++--- plugins/ShellExt/src/options.cpp | 2 +- plugins/ShellExt/src/shlcom.cpp | 60 +++++++------- plugins/ShellExt/src/shlext.cpp | 154 ++++++++++++++++++------------------ plugins/ShellExt/src/shlfactory.cpp | 8 +- plugins/ShellExt/src/shlicons.cpp | 16 ++-- plugins/ShellExt/src/shlipc.cpp | 38 ++++----- 7 files changed, 150 insertions(+), 150 deletions(-) (limited to 'plugins/ShellExt') diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp index fbb8b79131..c356ef7b94 100644 --- a/plugins/ShellExt/src/main.cpp +++ b/plugins/ShellExt/src/main.cpp @@ -25,7 +25,7 @@ PLUGININFOEX pluginInfoEx = { BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID) { if (fdwReason == DLL_PROCESS_ATTACH) { - bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != NULL; + bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != nullptr; GetTempPath(_countof(tszLogPath), tszLogPath); wcscat_s(tszLogPath, _countof(tszLogPath), L"shlext.log"); @@ -67,7 +67,7 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) RpcStringFreeA(&szGuid); #endif - *ppv = NULL; + *ppv = nullptr; return CLASS_E_CLASSNOTAVAILABLE; } @@ -83,8 +83,8 @@ STDAPI DllCanUnloadNow() struct HRegKey { - HRegKey(HKEY hRoot, const wchar_t *ptszKey) : m_key(NULL) - { RegCreateKeyEx(hRoot, ptszKey, 0, 0, 0, KEY_SET_VALUE | KEY_CREATE_SUB_KEY, 0, &m_key, 0); + HRegKey(HKEY hRoot, const wchar_t *ptszKey) : m_key(nullptr) + { RegCreateKeyEx(hRoot, ptszKey, 0, nullptr, 0, KEY_SET_VALUE | KEY_CREATE_SUB_KEY, nullptr, &m_key, nullptr); } ~HRegKey() { if (m_key) RegCloseKey(m_key); } @@ -103,11 +103,11 @@ char str4[] = "Apartment"; STDAPI DllRegisterServer() { HRegKey k1(HKEY_CLASSES_ROOT, L"miranda.shlext"); - if (k1 == NULL) + if (k1 == nullptr) return E_FAIL; int str1len = sprintf_s(str1, sizeof(str1), "shlext %d.%d.%d.%d - shell context menu support for Miranda NG", __FILEVERSION_STRING); - if ( RegSetValueA(k1, NULL, REG_SZ, str1, str1len)) + if ( RegSetValueA(k1, nullptr, REG_SZ, str1, str1len)) return E_FAIL; if ( RegSetValueA(k1, "CLSID", REG_SZ, str2, sizeof(str2))) return E_FAIL; @@ -115,21 +115,21 @@ STDAPI DllRegisterServer() ////////////////////////////////////////////////////////////////////////////////////// HRegKey kClsid(HKEY_CLASSES_ROOT, L"CLSID\\{72013A26-A94C-11d6-8540-A5E62932711D}"); - if (kClsid == NULL) + if (kClsid == nullptr) return E_FAIL; - if ( RegSetValueA(kClsid, NULL, REG_SZ, str3, sizeof(str3))) + if ( RegSetValueA(kClsid, nullptr, REG_SZ, str3, sizeof(str3))) return E_FAIL; if ( RegSetValueA(kClsid, "ProgID", REG_SZ, str3, sizeof(str3))) return E_FAIL; HRegKey kInprocServer(kClsid, L"InprocServer32"); - if (kInprocServer == NULL) + if (kInprocServer == nullptr) return E_FAIL; wchar_t tszFileName[MAX_PATH]; GetModuleFileName(hInst, tszFileName, _countof(tszFileName)); - if ( RegSetValueEx(kInprocServer, NULL, 0, REG_SZ, (LPBYTE)tszFileName, sizeof(wchar_t)*(lstrlen(tszFileName)+1))) + if ( RegSetValueEx(kInprocServer, nullptr, 0, REG_SZ, (LPBYTE)tszFileName, sizeof(wchar_t)*(lstrlen(tszFileName)+1))) return E_FAIL; if ( RegSetValueExA(kInprocServer, "ThreadingModel", 0, REG_SZ, (PBYTE)str4, sizeof(str4))) return E_FAIL; @@ -144,7 +144,7 @@ STDAPI DllRegisterServer() ////////////////////////////////////////////////////////////////////////////////////// HRegKey k2(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"); - if (k2 == NULL) + if (k2 == nullptr) return E_FAIL; if ( RegSetValueExA(k2, str2, 0, REG_SZ, (PBYTE)str1, str1len)) return E_FAIL; diff --git a/plugins/ShellExt/src/options.cpp b/plugins/ShellExt/src/options.cpp index a4ee4a20ac..aaa3f77f7f 100644 --- a/plugins/ShellExt/src/options.cpp +++ b/plugins/ShellExt/src/options.cpp @@ -86,7 +86,7 @@ static INT_PTR CALLBACK OptDialogProc(HWND hwndDlg, UINT wMsg, WPARAM wParam, LP EnableWindow(GetDlgItem(hwndDlg, IDC_CLISTGROUPS), BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_USEGROUPS)); break; case IDC_REMOVE: - if (IDYES == MessageBox(0, + if (IDYES == MessageBox(nullptr, TranslateT("Are you sure? This will remove all the settings stored in your database and all registry entries created for shlext to work with Explorer"), TranslateT("Disable/Remove shlext"), MB_YESNO | MB_ICONQUESTION)) { db_unset(0, SHLExt_Name, SHLExt_UseGroups); diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index 6aaa1dde2f..94cce6dece 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -34,7 +34,7 @@ int IsCOMRegistered() if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, KEY_READ, &hRegKey)) { DWORD lpType = REG_SZ; - if (!RegQueryValueEx(hRegKey, L"{72013A26-A94C-11d6-8540-A5E62932711D}", NULL, &lpType, 0, 0)) + if (!RegQueryValueEx(hRegKey, L"{72013A26-A94C-11d6-8540-A5E62932711D}", nullptr, &lpType, nullptr, nullptr)) res += COMREG_APPROVED; RegCloseKey(hRegKey); } @@ -138,10 +138,10 @@ void __cdecl IssueTransferThread(void *param) TAddArgList args; args.count = 0; - args.files = NULL; + args.files = nullptr; TSlotIPC *pct = pipch->DataPtr; BOOL bQuit = false; - while (pct != NULL) { + while (pct != nullptr) { if (pct->cbSize != sizeof(TSlotIPC)) break; args.szFile = LPSTR(UINT_PTR(pct) + sizeof(TSlotIPC)); @@ -153,11 +153,11 @@ void __cdecl IssueTransferThread(void *param) pct = pct->Next; } // while - if (args.files != NULL) { + if (args.files != nullptr) { args.files = (LPSTR*)mir_realloc(args.files, (args.count + 1) * sizeof(LPSTR)); - args.files[args.count++] = NULL; + args.files[args.count++] = nullptr; if (!bQuit) { - args.hEvent = CreateEvent(NULL, true, false, NULL); + args.hEvent = CreateEvent(nullptr, true, false, nullptr); QueueUserAPC(MainThreadIssueTransfer, hMainThread, UINT_PTR(&args)); while (true) { if (WaitForSingleObjectEx(args.hEvent, INFINITE, true) != WAIT_IO_COMPLETION) @@ -203,7 +203,7 @@ void ipcGetSkinIcons(THeaderIPC *ipch) DWORD dwCaps = CallService(szTmp, PFLAGNUM_1, 0); if (dwCaps & PF1_FILESEND) { TSlotIPC *pct = ipcAlloc(ipch, sizeof(TSlotProtoIcons)); - if (pct != NULL) { + if (pct != nullptr) { // capture all the icons! spi.hProto = murmur_hash(pa->szModuleName); for (int j = 0; j <= 10; j++) @@ -211,7 +211,7 @@ void ipcGetSkinIcons(THeaderIPC *ipch) pct->fType = REQUEST_NEWICONS; memcpy(LPSTR(pct) + sizeof(TSlotIPC), &spi, sizeof(TSlotProtoIcons)); - if (ipch->NewIconsBegin == NULL) + if (ipch->NewIconsBegin == nullptr) ipch->NewIconsBegin = pct; } } @@ -222,13 +222,13 @@ void ipcGetSkinIcons(THeaderIPC *ipch) // add Miranda icon TSlotIPC *pct = ipcAlloc(ipch, sizeof(TSlotProtoIcons)); - if (pct != NULL) { + if (pct != nullptr) { memset(&spi.hIcons, 0, sizeof(spi.hIcons)); spi.hProto = 0; // no protocol spi.hIcons[0] = Skin_LoadIcon(SKINICON_OTHER_MIRANDA); pct->fType = REQUEST_NEWICONS; memcpy(LPSTR(pct) + sizeof(TSlotIPC), &spi, sizeof(TSlotProtoIcons)); - if (ipch->NewIconsBegin == NULL) + if (ipch->NewIconsBegin == nullptr) ipch->NewIconsBegin = pct; } } @@ -258,7 +258,7 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) // do they have a running protocol? char *szProto = GetContactProto(hContact); - if (szProto != NULL) { + if (szProto != nullptr) { // does it support file sends? DWORD dwCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); if ((dwCaps & PF1_FILESEND) == 0) @@ -309,7 +309,7 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) int cch = lstrlenA(szContact) + 1; TSlotIPC *pct = ipcAlloc(ipch, cch + 1 + lstrlenA(szGroup) + 1); - if (pct == NULL) + if (pct == nullptr) break; // lie about the actual size of the TSlotIPC @@ -321,7 +321,7 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) pct->Status = pContacts[i].dwStatus; pct->hProto = pContacts[i].hProto; pct->MRU = db_get_b(pct->hContact, SHLExt_Name, SHLExt_MRU, 0); - if (ipch->ContactsBegin == NULL) + if (ipch->ContactsBegin == nullptr) ipch->ContactsBegin = pct; szSlot += cch + 1; if (szGroup != 0) { @@ -359,13 +359,13 @@ void __stdcall ipcService(ULONG_PTR) // try to open the file mapping object the caller must make sure no other // running instance is using this file HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, IPC_PACKET_NAME); - if (hMap == 0) + if (hMap == nullptr) return; // map the file to this process THeaderIPC *pMMT = (THeaderIPC*)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); // if it fails the caller should of had some timeout in wait - if (pMMT != NULL && pMMT->cbSize == sizeof(THeaderIPC) && pMMT->dwVersion == PLUGIN_MAKE_VERSION(2, 0, 1, 2)) { + if (pMMT != nullptr && pMMT->cbSize == sizeof(THeaderIPC) && pMMT->dwVersion == PLUGIN_MAKE_VERSION(2, 0, 1, 2)) { // toggle the right bits int *bits = &pMMT->fRequests; // jump right to a worker thread for file processing? @@ -382,7 +382,7 @@ void __stdcall ipcService(ULONG_PTR) } // the request was to clear the MRU entries, we have no return data if (*bits & REQUEST_CLEARMRU) { - mir_forkthread(&ClearMRUThread, NULL); + mir_forkthread(&ClearMRUThread, nullptr); goto Reply; } // the IPC header may have pointers that need to be translated @@ -417,12 +417,12 @@ void __stdcall ipcService(ULONG_PTR) if (bGroupMode && BST_CHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseCListSetting, BST_UNCHECKED)) bGroupMode = db_get_b(0, "CList", "UseGroups", true) != 0; - TSlotIPC *pct = NULL; + TSlotIPC *pct = nullptr; int iSlot = 0; // return profile if set if (BST_UNCHECKED == db_get_b(0, SHLExt_Name, SHLExt_ShowNoProfile, BST_UNCHECKED)) { pct = ipcAlloc(pMMT, 50); - if (pct != NULL) { + if (pct != nullptr) { // will actually return with .dat if there's space for it, not what the docs say pct->Status = STATUS_PROFILENAME; Profile_GetNameA(49, (char*)pct + sizeof(TSlotIPC)); @@ -439,8 +439,8 @@ void __stdcall ipcService(ULONG_PTR) break; pct = ipcAlloc(pMMT, lstrlenA(dbv.pszVal + 1) + 1); // first byte has flags, need null term - if (pct != NULL) { - if (pMMT->GroupsBegin == NULL) + if (pct != nullptr) { + if (pMMT->GroupsBegin == nullptr) pMMT->GroupsBegin = pct; pct->fType = REQUEST_GROUPS; pct->hContact = 0; @@ -457,7 +457,7 @@ void __stdcall ipcService(ULONG_PTR) iSlot++; } // if there was no space left, it'll } on null - if (pct == NULL) + if (pct == nullptr) *bits = (*bits | GROUPS_NOTIMPL) & ~REQUEST_GROUPS; } // SHOULD check slot space. @@ -471,7 +471,7 @@ void __stdcall ipcService(ULONG_PTR) Reply: // get the handle the caller wants to be signalled on hSignal = OpenEventA(EVENT_ALL_ACCESS, false, pMMT->SignalEventName); - if (hSignal != 0) { + if (hSignal != nullptr) { SetEvent(hSignal); CloseHandle(hSignal); } @@ -484,7 +484,7 @@ Reply: void __cdecl ThreadServer(HANDLE hMainThread) { char szBuf[100]; - HANDLE hEvent = CreateEventA(NULL, false, false, CreateProcessUID(GetCurrentProcessId(), szBuf, sizeof(szBuf))); + HANDLE hEvent = CreateEventA(nullptr, false, false, CreateProcessUID(GetCurrentProcessId(), szBuf, sizeof(szBuf))); while (true) { int retVal = WaitForSingleObjectEx(hEvent, INFINITE, true); if (retVal == WAIT_OBJECT_0) @@ -499,9 +499,9 @@ void __cdecl ThreadServer(HANDLE hMainThread) void InvokeThreadServer() { - HANDLE hMainThread = 0; + HANDLE hMainThread = nullptr; DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, false, 0); - if (hMainThread != 0) + if (hMainThread != nullptr) mir_forkthread(&ThreadServer, hMainThread); } @@ -516,27 +516,27 @@ HRESULT RemoveCOMRegistryEntries() RegCloseKey(hRootKey); // delete it if (RegDeleteKey(HKEY_CLASSES_ROOT, L"miranda.shlext") != ERROR_SUCCESS) - MessageBox(0, + MessageBox(nullptr, TranslateT("Unable to delete registry key for 'shlext COM', this key may already be deleted or you may need admin rights."), TranslateT("Problem"), MB_ICONERROR); } if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, L"\\*\\shellex\\ContextMenuHandlers", 0, KEY_ALL_ACCESS, &hRootKey)) { if (RegDeleteKey(hRootKey, L"miranda.shlext") != ERROR_SUCCESS) - MessageBox(0, + MessageBox(nullptr, TranslateT("Unable to delete registry key for 'File context menu handlers', this key may already be deleted or you may need admin rights."), TranslateT("Problem"), MB_ICONERROR); RegCloseKey(hRootKey); } if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, L"Directory\\shellex\\ContextMenuHandlers", 0, KEY_ALL_ACCESS, &hRootKey)) { if (RegDeleteKey(hRootKey, L"miranda.shlext") != ERROR_SUCCESS) - MessageBox(0, + MessageBox(nullptr, TranslateT("Unable to delete registry key for 'Directory context menu handlers', this key may already be deleted or you may need admin rights."), TranslateT("Problem"), MB_ICONERROR); RegCloseKey(hRootKey); } if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, KEY_ALL_ACCESS, &hRootKey)) { if (RegDeleteValue(hRootKey, L"{72013A26-A94C-11d6-8540-A5E62932711D}") != ERROR_SUCCESS) { - MessageBox(0, + MessageBox(nullptr, TranslateT("Unable to delete registry entry for 'Approved context menu handlers', this key may already be deleted or you may need admin rights."), TranslateT("Problem"), MB_ICONERROR); } @@ -576,7 +576,7 @@ void CheckRegisterServer() if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, L"miranda.shlext", 0, KEY_READ, &hRegKey)) RegCloseKey(hRegKey); else if (bIsVistaPlus) { - MessageBox(0, + MessageBox(nullptr, TranslateT("Shell context menus requires your permission to register with Windows Explorer (one time only)."), TranslateT("Miranda NG - Shell context menus (shellext.dll)"), MB_OK | MB_ICONINFORMATION); // /s = silent diff --git a/plugins/ShellExt/src/shlext.cpp b/plugins/ShellExt/src/shlext.cpp index a8d87632f1..443b1c6eda 100644 --- a/plugins/ShellExt/src/shlext.cpp +++ b/plugins/ShellExt/src/shlext.cpp @@ -14,9 +14,9 @@ TShellExt::TShellExt() { hDllHeap = HeapCreate(0, 0, 0); // create an inmemory DC - HDC DC = GetDC(0); + HDC DC = GetDC(nullptr); hMemDC = CreateCompatibleDC(DC); - ReleaseDC(0, DC); + ReleaseDC(nullptr, DC); // keep count on the number of objects DllObjectCount++; } @@ -26,36 +26,36 @@ TShellExt::~TShellExt() // time to go byebye. // Note MRU menu is associated with a window (indirectly) so windows will free it. // free icons! - if (ProtoIcons != NULL) { + if (ProtoIcons != nullptr) { ULONG c = ProtoIconsCount; while (c > 0) { c--; TSlotProtoIcons *p = &ProtoIcons[c]; for (int j = 0; j < 10; j++) { - if (p->hIcons[j] != 0) + if (p->hIcons[j] != nullptr) DestroyIcon(p->hIcons[j]); - if (p->hBitmaps[j] != 0) + if (p->hBitmaps[j] != nullptr) DeleteObject(p->hBitmaps[j]); } } free(ProtoIcons); - ProtoIcons = NULL; + ProtoIcons = nullptr; } // free IDataObject reference if pointer exists - if (pDataObject != NULL) { + if (pDataObject != nullptr) { pDataObject->Release(); - pDataObject = NULL; + pDataObject = nullptr; } // free the heap and any memory allocated on it HeapDestroy(hDllHeap); // destroy the DC - if (hMemDC != 0) + if (hMemDC != nullptr) DeleteDC(hMemDC); } HRESULT TShellExt::QueryInterface(REFIID riid, void **ppvObject) { - if (ppvObject == NULL) + if (ppvObject == nullptr) return E_POINTER; if (riid == IID_IContextMenu) { @@ -75,7 +75,7 @@ HRESULT TShellExt::QueryInterface(REFIID riid, void **ppvObject) logA("TShellExt[%p] retrieved as IID_IUnknown: %d\n", this, RefCount); } else { - *ppvObject = NULL; + *ppvObject = nullptr; #ifdef LOG_ENABLED RPC_CSTR szGuid; UuidToStringA(&riid, &szGuid); @@ -116,11 +116,11 @@ HRESULT TShellExt::Initialize(PCIDLIST_ABSOLUTE, IDataObject *pdtobj, HKEY) // it contains a pointer to a function table containing the function pointer // address of GetData() - the instance data has to be passed explicitly since // all compiler magic has gone. - if (pdtobj == NULL) + if (pdtobj == nullptr) return E_INVALIDARG; // if an instance already exists, free it. - if (pDataObject != NULL) + if (pDataObject != nullptr) pDataObject->Release(); // store the new one and AddRef() it @@ -138,20 +138,20 @@ HRESULT TShellExt::GetCommandString(UINT_PTR, UINT, UINT*, LPSTR, UINT) void FreeGroupTreeAndEmptyGroups(HMENU hParentMenu, TGroupNode *pp, TGroupNode *p) { - while (p != NULL) { + while (p != nullptr) { TGroupNode *q = p->Right; - if (p->Left != NULL) + if (p->Left != nullptr) FreeGroupTreeAndEmptyGroups(p->Left->hMenu, p, p->Left); if (p->dwItems == 0) { - if (pp != NULL) + if (pp != nullptr) DeleteMenu(pp->hMenu, p->hMenuGroupID, MF_BYCOMMAND); else DeleteMenu(hParentMenu, p->hMenuGroupID, MF_BYCOMMAND); } else // make sure this node's parent know's it exists - if (pp != NULL) + if (pp != nullptr) pp->dwItems++; free(p); @@ -166,7 +166,7 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum // get the heap object HANDLE hDllHeap = lParam->Self->hDllHeap; TMenuDrawInfo *psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo)); - if (pct != NULL) { + if (pct != nullptr) { psd->cch = pct->cbStrSection - 1; // no null; psd->szText = (char*)HeapAlloc(hDllHeap, 0, pct->cbStrSection); lstrcpyA(psd->szText, (char*)pct + sizeof(TSlotIPC)); @@ -175,7 +175,7 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum // find the protocol icon array to use && which status UINT c = lParam->Self->ProtoIconsCount; TSlotProtoIcons *pp = lParam->Self->ProtoIcons; - psd->hStatusIcon = 0; + psd->hStatusIcon = nullptr; while (c > 0) { c--; if (pp[c].hProto == pct->hProto && pp[c].pid == lParam->pid) { @@ -186,7 +186,7 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum } // while psd->pid = lParam->pid; } - else if (pg != NULL) { + else if (pg != nullptr) { // store the given ID pg->hMenuGroupID = mii.wID; // steal the pointer from the group node it should be on the heap @@ -195,7 +195,7 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum psd->fTypes = dtGroup; } // if psd->wID = mii.wID; - psd->szProfile = NULL; + psd->szProfile = nullptr; // store mii.dwItemData = UINT_PTR(psd); @@ -206,13 +206,13 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum else { // normal menu mii.fType = MFT_STRING; - if (pct != NULL) + if (pct != nullptr) mii.dwTypeData = LPSTR(pct) + sizeof(TSlotIPC); else mii.dwTypeData = pg->szGroup; // For Vista + let the system draw the theme && icons, pct = contact associated data - if (bIsVistaPlus && pct != NULL && psd != NULL) { + if (bIsVistaPlus && pct != nullptr && psd != nullptr) { mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID | MIIM_DATA | MIIM_STRING; // BuildSkinIcons() built an array of bitmaps which we can use here mii.hbmpItem = psd->hStatusBitmap; @@ -263,7 +263,7 @@ void BuildContactTree(TGroupNode *group, TEnumData *lParam) // go thru all the contacts TSlotIPC *pct = lParam->ipch->ContactsBegin; - while (pct != NULL && pct->cbSize == sizeof(TSlotIPC) && pct->fType == REQUEST_CONTACTS) { + while (pct != nullptr && pct->cbSize == sizeof(TSlotIPC) && pct->fType == REQUEST_CONTACTS) { if (pct->hGroup != 0) { // at the } of the slot header is the contact's display name // && after a double NULL char there is the group string, which has the full path of the group @@ -276,10 +276,10 @@ void BuildContactTree(TGroupNode *group, TEnumData *lParam) // restore the root TGroupNode *pg = group; int Depth = 0; - while (sz != NULL) { + while (sz != nullptr) { UINT Hash = murmur_hash(sz); // find this node within - while (pg != NULL) { + while (pg != nullptr) { // does this node have the right hash and the right depth? if (Hash == pg->Hash && Depth == pg->Depth) break; @@ -287,9 +287,9 @@ void BuildContactTree(TGroupNode *group, TEnumData *lParam) // the path syntax doesn't know if a group is a group at the same level // or a nested one, which means the search node can be anywhere TGroupNode *px = pg->Left; - if (px != NULL) { + if (px != nullptr) { // keep searching this level - while (px != NULL) { + while (px != nullptr) { if (Hash == px->Hash && Depth == px->Depth) { // found the node we're looking for at the next level to pg, px is now pq for next time pg = px; @@ -303,11 +303,11 @@ void BuildContactTree(TGroupNode *group, TEnumData *lParam) grouploop: Depth++; // process next token - sz = strtok(NULL, "\\"); + sz = strtok(nullptr, "\\"); } // tokenisation finished, if pg != NULL the group is found - if (pg != NULL) { - DecideMenuItemInfo(pct, NULL, mii, lParam); + if (pg != nullptr) { + DecideMenuItemInfo(pct, nullptr, mii, lParam); BuildMRU(pct, mii, lParam); InsertMenuItemA(pg->hMenu, 0xFFFFFFFF, true, &mii); pg->dwItems++; @@ -324,12 +324,12 @@ static void BuildMenuGroupTree(TGroupNode *p, TEnumData *lParam, HMENU hLastMenu mii.fMask = MIIM_ID | MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU; // go thru each group and create a menu for it adding submenus too. - while (p != NULL) { + while (p != nullptr) { mii.hSubMenu = CreatePopupMenu(); - if (p->Left != NULL) + if (p->Left != nullptr) BuildMenuGroupTree(p->Left, lParam, mii.hSubMenu); p->hMenu = mii.hSubMenu; - DecideMenuItemInfo(NULL, p, mii, lParam); + DecideMenuItemInfo(nullptr, p, mii, lParam); InsertMenuItemA(hLastMenu, 0xFFFFFFFF, true, &mii); p = p->Right; } @@ -344,9 +344,9 @@ static void BuildMenus(TEnumData *lParam) HMENU hBaseMenu = lParam->Self->hRootMenu; // build an in memory tree of the groups - TGroupNodeList j = { 0, 0 }; + TGroupNodeList j = { nullptr, nullptr }; TSlotIPC *pg = lParam->ipch->GroupsBegin; - while (pg != NULL) { + while (pg != nullptr) { if (pg->cbSize != sizeof(TSlotIPC) || pg->fType != REQUEST_GROUPS) break; @@ -354,11 +354,11 @@ static void BuildMenus(TEnumData *lParam) TGroupNode *p = j.First; // start at root again // get the group Token = strtok(LPSTR(pg) + sizeof(TSlotIPC), "\\"); - while (Token != NULL) { + while (Token != nullptr) { UINT Hash = murmur_hash(Token); // if the (sub)group doesn't exist, create it. TGroupNode *q = FindGroupNode(p, Hash, Depth); - if (q == NULL) { + if (q == nullptr) { q = AllocGroupNode(&j, p, Depth); q->Depth = Depth; // this is the hash of this group node, but it can be anywhere @@ -376,7 +376,7 @@ static void BuildMenus(TEnumData *lParam) } p = q; Depth++; - Token = strtok(NULL, "\\"); + Token = strtok(nullptr, "\\"); } pg = pg->Next; } @@ -391,7 +391,7 @@ static void BuildMenus(TEnumData *lParam) lParam->Self->hRecentMenu = CreatePopupMenu(); lParam->Self->RecentCount = 0; // create group menus only if they exist! - if (lParam->ipch->GroupsBegin != NULL) { + if (lParam->ipch->GroupsBegin != nullptr) { BuildMenuGroupTree(j.First, lParam, hGroupMenu); // add contacts that have a group somewhere BuildContactTree(j.First, lParam); @@ -402,11 +402,11 @@ static void BuildMenus(TEnumData *lParam) mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; // add all the contacts that have no group (which maybe all of them) pg = lParam->ipch->ContactsBegin; - while (pg != NULL) { + while (pg != nullptr) { if (pg->cbSize != sizeof(TSlotIPC) || pg->fType != REQUEST_CONTACTS) break; if (pg->hGroup == 0) { - DecideMenuItemInfo(pg, NULL, mii, lParam); + DecideMenuItemInfo(pg, nullptr, mii, lParam); BuildMRU(pg, mii, lParam); InsertMenuItemA(hGroupMenu, 0xFFFFFFFF, true, &mii); } @@ -462,7 +462,7 @@ static void BuildMenus(TEnumData *lParam) else { // no items were attached to the MRU, delete the MRU menu DestroyMenu(lParam->Self->hRecentMenu); - lParam->Self->hRecentMenu = 0; + lParam->Self->hRecentMenu = nullptr; } // allocate display info/memory for "Miranda" string @@ -484,8 +484,8 @@ static void BuildMenus(TEnumData *lParam) lstrcpynA(psd->szText, lParam->ipch->MirandaName, sizeof(lParam->ipch->MirandaName) - 1); // there may not be a profile name pg = lParam->ipch->DataPtr; - psd->szProfile = NULL; - if (pg != NULL && pg->Status == STATUS_PROFILENAME) { + psd->szProfile = nullptr; + if (pg != nullptr && pg->Status == STATUS_PROFILENAME) { psd->szProfile = (LPSTR)HeapAlloc(hDllHeap, 0, pg->cbStrSection); lstrcpyA(psd->szProfile, LPSTR(UINT_PTR(pg) + sizeof(TSlotIPC))); } @@ -522,16 +522,16 @@ static void BuildMenus(TEnumData *lParam) // add it all InsertMenuItemA(hBaseMenu, 0, true, &mii); // free the group tree - FreeGroupTreeAndEmptyGroups(hGroupMenu, NULL, j.First); + FreeGroupTreeAndEmptyGroups(hGroupMenu, nullptr, j.First); } static void BuildSkinIcons(TEnumData *lParam) { - IWICImagingFactory *factory = (bIsVistaPlus) ? ARGB_GetWorker() : NULL; + IWICImagingFactory *factory = (bIsVistaPlus) ? ARGB_GetWorker() : nullptr; TSlotIPC *pct = lParam->ipch->NewIconsBegin; TShellExt *Self = lParam->Self; - while (pct != NULL) { + while (pct != nullptr) { if (pct->cbSize != sizeof(TSlotIPC) || pct->fType != REQUEST_NEWICONS) break; @@ -547,10 +547,10 @@ static void BuildSkinIcons(TEnumData *lParam) for (int j = 0; j < 10; j++) { if (bIsVistaPlus) { d->hBitmaps[j] = ARGB_BitmapFromIcon(factory, Self->hMemDC, p->hIcons[j]); - d->hIcons[j] = NULL; + d->hIcons[j] = nullptr; } else { - d->hBitmaps[j] = NULL; + d->hBitmaps[j] = nullptr; d->hIcons[j] = CopyIcon(p->hIcons[j]); } } @@ -576,7 +576,7 @@ BOOL __stdcall ProcessRequest(HWND hwnd, LPARAM param) // this was fine for most Oses (not the best way) but now actually compares // the class string (a bit slower) but should get rid of those bugs finally. HANDLE hMirandaWorkEvent = OpenEventA(EVENT_ALL_ACCESS, false, CreateProcessUID(pid, szBuf, sizeof(szBuf))); - if (hMirandaWorkEvent != 0) { + if (hMirandaWorkEvent != nullptr) { GetClassNameA(hwnd, szBuf, sizeof(szBuf)); if ( lstrcmpA(szBuf, MIRANDACLASS) != 0) { // opened but not valid. @@ -586,7 +586,7 @@ BOOL __stdcall ProcessRequest(HWND hwnd, LPARAM param) } } // if the event object exists, a shlext.dll running in the instance must of created it. - if (hMirandaWorkEvent != 0) { + if (hMirandaWorkEvent != nullptr) { logA("ProcessRequest(%d, %p): window found\n", pid, hwnd); // prep the request ipcPrepareRequests(IPC_PACKET_SIZE, lParam->ipch, REQUEST_ICONS | REQUEST_GROUPS | REQUEST_CONTACTS | REQUEST_NEWICONS); @@ -598,7 +598,7 @@ BOOL __stdcall ProcessRequest(HWND hwnd, LPARAM param) // replyBits will be REPLY_FAIL if the wait timed out, or it'll be the request // bits as sent or a series of *_NOTIMPL bits where the request bit were, if there are no // contacts to speak of, don't bother showing this instance of Miranda } - if (replyBits != REPLY_FAIL && lParam->ipch->ContactsBegin != NULL) { + if (replyBits != REPLY_FAIL && lParam->ipch->ContactsBegin != nullptr) { logA("ProcessRequest(%d, %p): IPC succeeded\n", pid, hwnd); // load the address again, the server side will always overwrite it lParam->ipch->pClientBaseAddress = lParam->ipch; @@ -639,7 +639,7 @@ HRESULT TShellExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT _idCmdFirs bool bMF_OWNERDRAW = false; // get the shell version pfnDllGetVersion DllGetVersionProc = (pfnDllGetVersion)GetProcAddress( GetModuleHandleA("shell32.dll"), "DllGetVersion"); - if (DllGetVersionProc != NULL) { + if (DllGetVersionProc != nullptr) { DllVersionInfo dvi; dvi.cbSize = sizeof(dvi); if (DllGetVersionProc(&dvi) >= 0) // it's at least 4.00 @@ -650,12 +650,12 @@ HRESULT TShellExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT _idCmdFirs if (bIsVistaPlus) bMF_OWNERDRAW = false; - HANDLE hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, IPC_PACKET_SIZE, IPC_PACKET_NAME); - if (hMap != 0 && GetLastError() != ERROR_ALREADY_EXISTS) { - TEnumData ed = { 0 }; + HANDLE hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, IPC_PACKET_SIZE, IPC_PACKET_NAME); + if (hMap != nullptr && GetLastError() != ERROR_ALREADY_EXISTS) { + TEnumData ed = {}; // map the memory to this address space THeaderIPC *pipch = (THeaderIPC*)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); - if (pipch != NULL) { + if (pipch != nullptr) { // let the callback have instance vars ed.Self = this; // not used 'ere @@ -671,8 +671,8 @@ HRESULT TShellExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT _idCmdFirs // since it has to used by OpenEvent() CreateUID(pipch->SignalEventName, sizeof(pipch->SignalEventName)); // create the wait wait-for-wait object - ed.hWaitFor = CreateEventA(NULL, false, false, pipch->SignalEventName); - if (ed.hWaitFor != 0) { + ed.hWaitFor = CreateEventA(nullptr, false, false, pipch->SignalEventName); + if (ed.hWaitFor != nullptr) { // enumerate all the top level windows to find all loaded MIRANDACLASS classes EnumWindows(&ProcessRequest, LPARAM(&ed)); // close the wait-for-reply object @@ -699,7 +699,7 @@ HRESULT ipcGetFiles(THeaderIPC *pipch, IDataObject* pDataObject, MCONTACT hConta { FORMATETC fet; fet.cfFormat = CF_HDROP; - fet.ptd = NULL; + fet.ptd = nullptr; fet.dwAspect = DVASPECT_CONTENT; fet.lindex = -1; fet.tymed = TYMED_HGLOBAL; @@ -709,16 +709,16 @@ HRESULT ipcGetFiles(THeaderIPC *pipch, IDataObject* pDataObject, MCONTACT hConta if (hr == S_OK) { // FIX, actually lock the global object and get a pointer HANDLE hDrop = GlobalLock(stgm.hGlobal); - if (hDrop != 0) { + if (hDrop != nullptr) { // get the maximum number of files - UINT iFile, iFileMax = DragQueryFileA((HDROP)stgm.hGlobal, -1, NULL, 0); + UINT iFile, iFileMax = DragQueryFileA((HDROP)stgm.hGlobal, -1, nullptr, 0); for (iFile = 0; iFile < iFileMax; iFile++) { // get the size of the file path - int cbSize = DragQueryFileA((HDROP)stgm.hGlobal, iFile, NULL, 0); + int cbSize = DragQueryFileA((HDROP)stgm.hGlobal, iFile, nullptr, 0); // get the buffer TSlotIPC *pct = ipcAlloc(pipch, cbSize + 1); // including null term // allocated? - if (pct == NULL) + if (pct == nullptr) break; // store the hContact pct->hContact = hContact; @@ -747,27 +747,27 @@ HRESULT RequestTransfer(TShellExt *Self, int idxCmd) // get the pointer TMenuDrawInfo *psd = (TMenuDrawInfo*)mii.dwItemData; // the ID stored in the item pointer and the ID for the menu must match - if (psd == NULL || psd->wID != mii.wID) + if (psd == nullptr || psd->wID != mii.wID) return E_INVALIDARG; // is there an IDataObject instance? HRESULT hr = E_INVALIDARG; - if (Self->pDataObject != NULL) { + if (Self->pDataObject != nullptr) { // OpenEvent() the work object to see if the instance is still around char szBuf[100]; HANDLE hTransfer = OpenEventA(EVENT_ALL_ACCESS, false, CreateProcessUID(psd->pid, szBuf, sizeof(szBuf))); - if (hTransfer != 0) { + if (hTransfer != nullptr) { // map the ipc file again - HANDLE hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, IPC_PACKET_SIZE, IPC_PACKET_NAME); - if (hMap != 0 && GetLastError() != ERROR_ALREADY_EXISTS) { + HANDLE hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, IPC_PACKET_SIZE, IPC_PACKET_NAME); + if (hMap != nullptr && GetLastError() != ERROR_ALREADY_EXISTS) { // map it to process THeaderIPC *pipch = (THeaderIPC*)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); - if (pipch != NULL) { + if (pipch != nullptr) { // create the name of the object to be signalled by the ST lstrcpyA(pipch->SignalEventName, CreateUID(szBuf, sizeof(szBuf))); // create it - HANDLE hReply = CreateEventA(NULL, false, false, pipch->SignalEventName); - if (hReply != 0) { + HANDLE hReply = CreateEventA(nullptr, false, false, pipch->SignalEventName); + if (hReply != nullptr) { if (psd->fTypes & dtCommand) { if (psd->MenuCommandCallback) hr = psd->MenuCommandCallback(pipch, hTransfer, hReply); @@ -811,7 +811,7 @@ HRESULT TShellExt::InvokeCommand(CMINVOKECOMMANDINFO *pici) HRESULT TShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) { LRESULT Dummy; - if (plResult == NULL) + if (plResult == nullptr) plResult = &Dummy; SIZE tS; @@ -857,7 +857,7 @@ HRESULT TShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESU dwi->rcItem.left += dwi->rcItem.bottom - dwi->rcItem.top - 2; DrawTextA(dwi->hDC, psd->szText, psd->cch, &dwi->rcItem, DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER); // draw the name of the database text if it's there - if (psd->szProfile != NULL) { + if (psd->szProfile != nullptr) { GetTextExtentPoint32A(dwi->hDC, psd->szText, psd->cch, &tS); dwi->rcItem.left += tS.cx + 8; SetTextColor(dwi->hDC, GetSysColor(COLOR_GRAYTEXT)); @@ -906,7 +906,7 @@ HRESULT TShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESU GetTextExtentPoint32A(hMemDC, psd->szText, psd->cch, &tS); dx += tS.cx; // main menu item? - if (psd->szProfile != NULL) { + if (psd->szProfile != nullptr) { GetTextExtentPoint32A(hMemDC, psd->szProfile, lstrlenA(psd->szProfile), &tS); dx += tS.cx; } @@ -924,5 +924,5 @@ HRESULT TShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESU HRESULT TShellExt::HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) { - return HandleMenuMsg2(uMsg, wParam, lParam, NULL); + return HandleMenuMsg2(uMsg, wParam, lParam, nullptr); } diff --git a/plugins/ShellExt/src/shlfactory.cpp b/plugins/ShellExt/src/shlfactory.cpp index 973dbb0aec..fba9fdabba 100644 --- a/plugins/ShellExt/src/shlfactory.cpp +++ b/plugins/ShellExt/src/shlfactory.cpp @@ -22,7 +22,7 @@ HRESULT TClassFactoryRec::QueryInterface(REFIID riid, void **ppvObject) logA("TClassFactoryRec::QueryInterface {%s} failed\n", szGuid); RpcStringFreeA(&szGuid); #endif - *ppvObject = NULL; + *ppvObject = nullptr; return E_NOINTERFACE; } @@ -49,15 +49,15 @@ ULONG TClassFactoryRec::Release() HRESULT TClassFactoryRec::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject) { - if (ppvObject == 0) + if (ppvObject == nullptr) return E_POINTER; - *ppvObject = NULL; + *ppvObject = nullptr; if (pUnkOuter) return CLASS_E_NOAGGREGATION; TShellExt *p = new TShellExt(); - if (p == NULL) + if (p == nullptr) return E_OUTOFMEMORY; HRESULT hr = p->QueryInterface(riid, ppvObject); diff --git a/plugins/ShellExt/src/shlicons.cpp b/plugins/ShellExt/src/shlicons.cpp index 20f941a03e..8f9162a7c0 100644 --- a/plugins/ShellExt/src/shlicons.cpp +++ b/plugins/ShellExt/src/shlicons.cpp @@ -22,14 +22,14 @@ Why didn't they just do this themselves? ... IWICImagingFactory* ARGB_GetWorker() { - IWICImagingFactory *res = NULL; - CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (void**)&res); + IWICImagingFactory *res = nullptr; + CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (void**)&res); return res; } HBITMAP ARGB_BitmapFromIcon(IWICImagingFactory *Factory, HDC hDC, HICON hIcon) { - HBITMAP hBmp = NULL; + HBITMAP hBmp = nullptr; // This code gives an icon to WIC and gets a bitmap object in return, it then creates a DIB section // which is 32bits and the same H*W as the icon. It then asks the bitmap object to copy itself into the DIB } @@ -40,7 +40,7 @@ HBITMAP ARGB_BitmapFromIcon(IWICImagingFactory *Factory, HDC hDC, HICON hIcon) bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biBitCount = 32; - IWICBitmap *bitmap = NULL; + IWICBitmap *bitmap = nullptr; HRESULT hr = Factory->CreateBitmapFromHICON(hIcon, &bitmap); if (hr == S_OK) { int cx, cy; @@ -50,16 +50,16 @@ HBITMAP ARGB_BitmapFromIcon(IWICImagingFactory *Factory, HDC hDC, HICON hIcon) bmi.bmiHeader.biHeight = -cy; void *pbBuffer; - hBmp = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pbBuffer, 0, 0); - if (hBmp != 0) { + hBmp = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pbBuffer, nullptr, 0); + if (hBmp != nullptr) { UINT cbStride = cx * sizeof(DWORD); // ARGB = DWORD UINT cbBuffer = cy * cbStride; // note: the pbBuffer memory is owned by the DIB and will be freed when the bitmap is released - hr = bitmap->CopyPixels(NULL, cbStride, cbBuffer, (PBYTE)pbBuffer); + hr = bitmap->CopyPixels(nullptr, cbStride, cbBuffer, (PBYTE)pbBuffer); if (hr != S_OK) { // the copy failed, delete the DIB DeleteObject(hBmp); - hBmp = NULL; + hBmp = nullptr; } } } diff --git a/plugins/ShellExt/src/shlipc.cpp b/plugins/ShellExt/src/shlipc.cpp index 41a195af77..ac2ba3ef01 100644 --- a/plugins/ShellExt/src/shlipc.cpp +++ b/plugins/ShellExt/src/shlipc.cpp @@ -3,13 +3,13 @@ TGroupNode* FindGroupNode(TGroupNode *p, const DWORD Hash, int Depth) { - while (p != NULL) { + while (p != nullptr) { if (p->Hash == Hash && p->Depth == Depth) return p; - if (p->Left != NULL) { + if (p->Left != nullptr) { TGroupNode *q = FindGroupNode(p->Left, Hash, Depth); - if (q != NULL) + if (q != nullptr) return q; } p = p->Right; @@ -22,19 +22,19 @@ TGroupNode* AllocGroupNode(TGroupNodeList *list, TGroupNode *Root, int Depth) TGroupNode *p = (TGroupNode*)calloc(1, sizeof(TGroupNode)); p->Depth = Depth; if (Depth > 0) { - if (Root->Left == NULL) + if (Root->Left == nullptr) Root->Left = p; else { Root = Root->Left; - while (Root->Right != NULL) + while (Root->Right != nullptr) Root = Root->Right; Root->Right = p; } } else { - if (list->First == NULL) + if (list->First == nullptr) list->First = p; - if (list->Last != NULL) + if (list->Last != nullptr) list->Last->Right = p; list->Last = p; } @@ -47,14 +47,14 @@ void ipcPrepareRequests(int ipcPacketSize, THeaderIPC *pipch, DWORD fRequests) pipch->cbSize = sizeof(THeaderIPC); pipch->dwVersion = PLUGIN_MAKE_VERSION(2, 0, 1, 2); pipch->dwFlags = 0; - pipch->pServerBaseAddress = NULL; + pipch->pServerBaseAddress = nullptr; pipch->pClientBaseAddress = pipch; pipch->fRequests = fRequests; pipch->Slots = 0; - pipch->IconsBegin = NULL; - pipch->ContactsBegin = NULL; - pipch->GroupsBegin = NULL; - pipch->NewIconsBegin = NULL; + pipch->IconsBegin = nullptr; + pipch->ContactsBegin = nullptr; + pipch->GroupsBegin = nullptr; + pipch->NewIconsBegin = nullptr; pipch->DataSize = ipcPacketSize - pipch->cbSize; // the server side will adjust these pointers as soon as it opens // the mapped file to it's base address, these are set 'ere because ipcAlloc() @@ -94,7 +94,7 @@ TSlotIPC* ipcAlloc(THeaderIPC *pipch, int nSize) UINT_PTR PSP = UINT_PTR(pipch->DataFramePtr) + sizeof(TSlotIPC) + nSize; // is it past the end? if (PSP >= UINT_PTR(pipch->DataPtrEnd)) - return NULL; + return nullptr; // return the pointer TSlotIPC *p = (TSlotIPC*)pipch->DataFramePtr; // set up the item @@ -115,16 +115,16 @@ void ipcFixupAddresses(THeaderIPC *pipch) INT_PTR diff = INT_PTR(pipch->pClientBaseAddress) - INT_PTR(pipch->pServerBaseAddress); // fix up all the pointers in the header - if (pipch->IconsBegin != NULL) + if (pipch->IconsBegin != nullptr) pipch->IconsBegin = (TSlotIPC*)(UINT_PTR(pipch->IconsBegin) + diff); - if (pipch->ContactsBegin != NULL) + if (pipch->ContactsBegin != nullptr) pipch->ContactsBegin = (TSlotIPC*)(UINT_PTR(pipch->ContactsBegin) + diff); - if (pipch->GroupsBegin != NULL) + if (pipch->GroupsBegin != nullptr) pipch->GroupsBegin = (TSlotIPC*)(UINT_PTR(pipch->GroupsBegin) + diff); - if (pipch->NewIconsBegin != NULL) + if (pipch->NewIconsBegin != nullptr) pipch->NewIconsBegin = (TSlotIPC*)(UINT_PTR(pipch->NewIconsBegin) + diff); pipch->DataPtr = (TSlotIPC*)(UINT_PTR(pipch->DataPtr) + diff); @@ -133,11 +133,11 @@ void ipcFixupAddresses(THeaderIPC *pipch) // and the link list TSlotIPC *pct = pipch->DataPtr; - while (pct != NULL) { + while (pct != nullptr) { // the first pointer is already fixed up, have to get a pointer // to the next pointer and modify where it jumps to TSlotIPC **q = &pct->Next; - if (*q != NULL) + if (*q != nullptr) *q = (TSlotIPC*)(UINT_PTR(*q) + diff); pct = *q; -- cgit v1.2.3