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 /plugins/CountryFlags/src | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/CountryFlags/src')
-rw-r--r-- | plugins/CountryFlags/src/icons.cpp | 62 | ||||
-rw-r--r-- | plugins/CountryFlags/src/ip2country.cpp | 16 | ||||
-rw-r--r-- | plugins/CountryFlags/src/utils.cpp | 16 |
3 files changed, 47 insertions, 47 deletions
diff --git a/plugins/CountryFlags/src/icons.cpp b/plugins/CountryFlags/src/icons.cpp index 966af46b11..e0d145dfe7 100644 --- a/plugins/CountryFlags/src/icons.cpp +++ b/plugins/CountryFlags/src/icons.cpp @@ -91,9 +91,9 @@ static int __fastcall CountryNumberToBitmapIndex(int countryNumber) // only operates on color icons, which isn't a problem here
static HICON __fastcall ResizeIconCentered(HICON hIcon,int cx,int cy)
{
- HICON hResIcon = NULL;
- HDC hdc = CreateCompatibleDC(NULL);
- if (hdc != NULL) {
+ HICON hResIcon = nullptr;
+ HDC hdc = CreateCompatibleDC(nullptr);
+ if (hdc != nullptr) {
ICONINFO icoi;
if ( GetIconInfo(hIcon,&icoi)) {
BITMAP bm;
@@ -102,22 +102,22 @@ static HICON __fastcall ResizeIconCentered(HICON hIcon,int cx,int cy) pt.x = (cx-bm.bmWidth)/2;
pt.y = (cy-bm.bmHeight)/2;
HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, icoi.hbmColor);
- if (hbmPrev != NULL) { /* error on select? */
+ if (hbmPrev != nullptr) { /* error on select? */
HBITMAP hbm = icoi.hbmColor;
icoi.hbmColor = CreateCompatibleBitmap(hdc,cx,cy);
- if (icoi.hbmColor != NULL)
- if (SelectObject(hdc,icoi.hbmColor) != NULL) { /* error on select? */
+ if (icoi.hbmColor != nullptr)
+ if (SelectObject(hdc,icoi.hbmColor) != nullptr) { /* error on select? */
DeleteObject(hbm); /* delete prev color (XOR) */
- if (BitBlt(hdc,0,0,cx,cy,NULL,0,0,BLACKNESS)) /* transparency: AND=0, XOR=1 */
- if (DrawIconEx(hdc,pt.x,pt.y,hIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_IMAGE|DI_NOMIRROR)) {
- if (SelectObject(hdc,icoi.hbmMask) != NULL) { /* error on select? */
+ if (BitBlt(hdc,0,0,cx,cy,nullptr,0,0,BLACKNESS)) /* transparency: AND=0, XOR=1 */
+ if (DrawIconEx(hdc,pt.x,pt.y,hIcon,bm.bmWidth,bm.bmHeight,0,nullptr,DI_IMAGE|DI_NOMIRROR)) {
+ if (SelectObject(hdc,icoi.hbmMask) != nullptr) { /* error on select? */
hbm = icoi.hbmMask;
- icoi.hbmMask = CreateBitmap(cx,cy,1,1,NULL); /* mono */
- if (icoi.hbmMask != NULL)
- if (SelectObject(hdc,icoi.hbmMask) != NULL) { /* error on select? */
+ icoi.hbmMask = CreateBitmap(cx,cy,1,1,nullptr); /* mono */
+ if (icoi.hbmMask != nullptr)
+ if (SelectObject(hdc,icoi.hbmMask) != nullptr) { /* error on select? */
DeleteObject(hbm); /* delete prev mask (AND) */
- if (BitBlt(hdc,0,0,cx,cy,NULL,0,0,WHITENESS)) /* transparency: AND=0, XOR=1 */
- if (DrawIconEx(hdc,pt.x,pt.y,hIcon,0,0,0,NULL,DI_MASK|DI_NOMIRROR)) {
+ if (BitBlt(hdc,0,0,cx,cy,nullptr,0,0,WHITENESS)) /* transparency: AND=0, XOR=1 */
+ if (DrawIconEx(hdc,pt.x,pt.y,hIcon,0,0,0,nullptr,DI_MASK|DI_NOMIRROR)) {
SelectObject(hdc,hbmPrev);
hResIcon = CreateIconIndirect(&icoi); /* bitmaps must not be selected */
}
@@ -142,7 +142,7 @@ HICON __fastcall LoadFlagIcon(int countryNumber) {
/* create identifier */
char *szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, countryNumber, 0);
- if (szCountry == NULL)
+ if (szCountry == nullptr)
szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, countryNumber = 0xFFFF, 0);
char szId[20];
@@ -168,7 +168,7 @@ static INT_PTR ServiceLoadFlagIcon(WPARAM wParam,LPARAM lParam) {
/* return handle */
if ((BOOL)lParam) {
- if (phIconHandles == NULL)
+ if (phIconHandles == nullptr)
return 0;
return (INT_PTR)phIconHandles[CountryNumberToIndex((int)wParam)];
@@ -179,10 +179,10 @@ static INT_PTR ServiceLoadFlagIcon(WPARAM wParam,LPARAM lParam) static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam)
{
- HICON hIcon=NULL;
+ HICON hIcon = nullptr;
/* load both icons */
HICON hLowerIcon = (HICON)ServiceLoadFlagIcon((WPARAM)lParam,0);
- if (hLowerIcon == NULL)
+ if (hLowerIcon == nullptr)
return 0;
HICON hUpperIcon = (HICON)ServiceLoadFlagIcon(wParam,0);
@@ -191,21 +191,21 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) ICONINFO icoi;
if (GetIconInfo(hLowerIcon, &icoi)) {
BITMAP bm;
- if (hUpperIcon != NULL && GetObject(icoi.hbmColor, sizeof(bm), &bm)) {
- HDC hdc = CreateCompatibleDC(NULL);
- if (hdc != NULL) {
+ if (hUpperIcon != nullptr && GetObject(icoi.hbmColor, sizeof(bm), &bm)) {
+ HDC hdc = CreateCompatibleDC(nullptr);
+ if (hdc != nullptr) {
POINT aptTriangle[3] = { 0 };
aptTriangle[1].y = bm.bmHeight-1;
aptTriangle[2].x = bm.bmWidth-1;
HRGN hrgn = CreatePolygonRgn(aptTriangle,_countof(aptTriangle),WINDING);
- if (hrgn != NULL) {
+ if (hrgn != nullptr) {
SelectClipRgn(hdc,hrgn);
DeleteObject(hrgn);
HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, icoi.hbmColor);
- if (hbmPrev != NULL) { /* error on select? */
- if ( DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_IMAGE))
- if ( SelectObject(hdc,icoi.hbmMask) != NULL) /* error on select? */
- DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_MASK);
+ if (hbmPrev != nullptr) { /* error on select? */
+ if ( DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,nullptr,DI_NOMIRROR|DI_IMAGE))
+ if ( SelectObject(hdc,icoi.hbmMask) != nullptr) /* error on select? */
+ DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,nullptr,DI_NOMIRROR|DI_MASK);
SelectObject(hdc,hbmPrev);
}
}
@@ -227,7 +227,7 @@ void InitIcons(void) char szId[20];
/* register icons */
- SKINICONDESC sid = { 0 };
+ SKINICONDESC sid = {};
sid.pszName = szId;
sid.cx = GetSystemMetrics(SM_CXSMICON);
sid.cy = GetSystemMetrics(SM_CYSMICON);
@@ -237,9 +237,9 @@ void InitIcons(void) /* all those flag icons do not need any transparency mask (flags are always opaque),
* storing them in a large bitmap to reduce file size */
HIMAGELIST himl = ImageList_LoadImage(hInst,MAKEINTRESOURCE(IDB_FLAGS),sid.cx,0,CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION);
- if (himl != NULL) {
+ if (himl != nullptr) {
phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
- if (phIconHandles != NULL) {
+ if (phIconHandles != nullptr) {
for (int i=0; i < nCountriesCount; ++i) {
sid.description.a = (char*)countries[i].szName;
@@ -252,10 +252,10 @@ void InitIcons(void) sid.hDefaultIcon = ResizeIconCentered(hIcon,sid.cx,sid.cy);
DestroyIcon(hIcon);
}
- else sid.hDefaultIcon = NULL;
+ else sid.hDefaultIcon = nullptr;
index = CountryNumberToIndex(countries[i].id);
phIconHandles[index] = IcoLib_AddIcon(&sid);
- if (sid.hDefaultIcon != NULL)
+ if (sid.hDefaultIcon != nullptr)
DestroyIcon(sid.hDefaultIcon);
}
}
diff --git a/plugins/CountryFlags/src/ip2country.cpp b/plugins/CountryFlags/src/ip2country.cpp index 1612d05c6d..d51373e7d2 100644 --- a/plugins/CountryFlags/src/ip2country.cpp +++ b/plugins/CountryFlags/src/ip2country.cpp @@ -34,7 +34,7 @@ static BYTE* GetDataHeader(BYTE *data,DWORD cbDataSize,DWORD *pnDataRecordCount) /* uncompressed size stored in first DWORD */
*pnDataRecordCount=(*(DWORD*)data)/DATARECORD_SIZE;
recordData=(BYTE*)mir_alloc(*(DWORD*)data);
- if (recordData != NULL)
+ if (recordData != nullptr)
Huffman_Uncompress(data+sizeof(DWORD),recordData,cbDataSize-sizeof(DWORD),*(DWORD*)data);
return recordData;
}
@@ -44,7 +44,7 @@ static int GetDataRecord(BYTE *data,DWORD index,DWORD *pdwFrom,DWORD *pdwTo) data+=index*DATARECORD_SIZE;
*pdwFrom=*(DWORD*)data;
data+=sizeof(DWORD);
- if (pdwTo != NULL) *pdwTo=*(DWORD*)data;
+ if (pdwTo != nullptr) *pdwTo=*(DWORD*)data;
data+=sizeof(DWORD);
return (int)*(WORD*)data;
}
@@ -61,7 +61,7 @@ static void CALLBACK UnloadRecordCache(LPARAM) {
mir_cslock lck(csRecordCache);
mir_free(dataRecords);
- dataRecords=NULL;
+ dataRecords=nullptr;
}
// function assumes it has got the csRecordCache mutex
@@ -70,16 +70,16 @@ static BOOL EnsureRecordCacheLoaded(BYTE **pdata,DWORD *pcount) HRSRC hrsrc;
DWORD cb;
mir_cslock lck(csRecordCache);
- if (dataRecords == NULL) {
+ if (dataRecords == nullptr) {
/* load record data list from resources */
hrsrc=FindResource(hInst,MAKEINTRESOURCE(IDR_IPTOCOUNTRY),L"BIN");
cb=SizeofResource(hInst,hrsrc);
dataRecords=(BYTE*)LockResource(LoadResource(hInst,hrsrc));
- if (cb<=sizeof(DWORD) || dataRecords == NULL)
+ if (cb<=sizeof(DWORD) || dataRecords == nullptr)
return FALSE;
/* uncompress record data */
dataRecords=GetDataHeader(dataRecords,cb,&nDataRecordsCount);
- if (dataRecords == NULL || !nDataRecordsCount)
+ if (dataRecords == nullptr || !nDataRecordsCount)
return FALSE;
}
*pdata=dataRecords;
@@ -104,7 +104,7 @@ INT_PTR ServiceIpToCountry(WPARAM wParam, LPARAM) int id;
if (EnsureRecordCacheLoaded(&data,&high)) {
/* binary search in record data */
- GetDataRecord(data,low,&dwFrom,NULL);
+ GetDataRecord(data,low,&dwFrom,nullptr);
--high;
if (wParam>=dwFrom) /* only search if wParam valid */
while (low<=high) {
@@ -301,7 +301,7 @@ static void BinConvThread(void *unused) void InitIpToCountry(void)
{
nDataRecordsCount=0;
- dataRecords=NULL;
+ dataRecords=nullptr;
/* Services */
CreateServiceFunction(MS_FLAGS_IPTOCOUNTRY,ServiceIpToCountry);
#ifdef BINCONV
diff --git a/plugins/CountryFlags/src/utils.cpp b/plugins/CountryFlags/src/utils.cpp index 082f8f256e..96721a2eca 100644 --- a/plugins/CountryFlags/src/utils.cpp +++ b/plugins/CountryFlags/src/utils.cpp @@ -65,11 +65,11 @@ static void CALLBACK BufferedProcTimer(HWND hwnd, UINT, UINT_PTR idTimer, DWORD --i; /* reiterate current */
if (nCallListCount) {
buf = (struct BufferedCallData*)mir_realloc(callList, nCallListCount*sizeof(struct BufferedCallData));
- if (buf != NULL) callList = buf;
+ if (buf != nullptr) callList = buf;
}
else {
mir_free(callList);
- callList = NULL;
+ callList = nullptr;
}
#ifdef _DEBUG
mir_snprintf(szDbgLine, "buffered call: %s(0x%X)\n", pszProcName, lParam); /* all ascii */
@@ -106,7 +106,7 @@ void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, const char *pszProcName, LP void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumulateSameParam, UINT uElapse)
#endif
{
- struct BufferedCallData *data = NULL;
+ struct BufferedCallData *data = nullptr;
int i;
/* find existing */
@@ -117,10 +117,10 @@ void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumu break;
}
/* append new */
- if (data == NULL) {
+ if (data == nullptr) {
/* resize storage array */
data = (struct BufferedCallData*)mir_realloc(callList, (nCallListCount + 1)*sizeof(struct BufferedCallData));
- if (data == NULL) return;
+ if (data == nullptr) return;
callList = data;
data = &callList[nCallListCount];
++nCallListCount;
@@ -144,7 +144,7 @@ void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumu #endif
/* set next timer */
if (idBufferedTimer) uElapse = USER_TIMER_MINIMUM; /* will get recalculated */
- idBufferedTimer = SetTimer(NULL, idBufferedTimer, uElapse, BufferedProcTimer);
+ idBufferedTimer = SetTimer(nullptr, idBufferedTimer, uElapse, BufferedProcTimer);
}
// assumes to be called in context of main thread
@@ -152,13 +152,13 @@ void PrepareBufferedFunctions(void) {
idBufferedTimer = 0;
nCallListCount = 0;
- callList = NULL;
+ callList = nullptr;
}
// assumes to be called in context of main thread
void KillBufferedFunctions(void)
{
- if (idBufferedTimer) KillTimer(NULL, idBufferedTimer);
+ if (idBufferedTimer) KillTimer(nullptr, idBufferedTimer);
nCallListCount = 0;
mir_free(callList); /* does NULL check */
}
|