From 1c0172cca4f1e90679321912e20436a7f42f122d Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Sat, 24 Feb 2018 15:32:06 +0100 Subject: more nullptr --- include/m_chat.h | 4 +-- include/m_chat_int.h | 2 +- include/m_clist.h | 12 ++++----- include/m_contacts.h | 2 +- include/m_core.h | 20 +++++++------- include/m_database.h | 4 +-- include/m_db_int.h | 4 +-- include/m_extraicons.h | 6 ++--- include/m_genmenu.h | 2 +- include/m_gui.h | 6 ++--- include/m_jabber.h | 10 +++---- include/m_json.h | 2 +- include/m_netlib.h | 2 +- include/m_options.h | 4 +-- include/m_popup.h | 4 +-- include/m_string.h | 8 +++--- include/m_string.inl | 72 +++++++++++++++++++++++++------------------------- include/m_system.h | 2 +- include/m_system_cpp.h | 34 +++++++++++++++--------- include/m_timezones.h | 10 +++---- include/m_utils.h | 12 ++++----- 21 files changed, 115 insertions(+), 107 deletions(-) (limited to 'include') diff --git a/include/m_chat.h b/include/m_chat.h index f640d5f90b..e5fa914151 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -171,7 +171,7 @@ EXTERN_C MIR_APP_DLL(struct GCSessionInfoBase*) Chat_NewSession( const char *pszModule, // The name of the protocol owning the session (the same as pszModule when you register) const wchar_t *ptszID, // The unique identifier for the session. const wchar_t *ptszName, // The name of the session as it will be displayed to the user - void *pItemData = NULL // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call + void *pItemData = nullptr // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call ); /* @@ -372,7 +372,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT*); EXTERN_C MIR_APP_DLL(void*) Chat_GetUserInfo(const char *szModule, const wchar_t *wszId); EXTERN_C MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, void *pItemData); -EXTERN_C MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon = NULL); +EXTERN_C MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon = nullptr); EXTERN_C MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wszId, const wchar_t *wszNewName); EXTERN_C MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, const wchar_t *wszOldId, const wchar_t *wszNewId); EXTERN_C MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId, const wchar_t *wszText); diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 4af2db76e2..f90c7082a9 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -364,7 +364,7 @@ struct CHAT_MANAGER extern CHAT_MANAGER *pci; #endif -EXTERN_C MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pData = NULL, int = hLangpack); +EXTERN_C MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pData = nullptr, int = hLangpack); ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/m_clist.h b/include/m_clist.h index 1ef9117309..b3eb928deb 100644 --- a/include/m_clist.h +++ b/include/m_clist.h @@ -85,7 +85,7 @@ EXTERN_C MIR_APP_DLL(HMENU) Menu_GetMainMenu(void); // adds a new element into contact menu -EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddContactMenuItem(TMO_MenuItem *pmi, const char *pszProto = NULL); +EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddContactMenuItem(TMO_MenuItem *pmi, const char *pszProto = nullptr); // builds the context menu for a specific contact // returns a HMENU identifying the menu. This should be DestroyMenu()ed when @@ -109,7 +109,7 @@ EXTERN_C MIR_APP_DLL(HMENU) Menu_GetStatusMenu(void); // adds an item to a status menu -EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddStatusMenuItem(TMO_MenuItem *pmi, const char *pszProto = NULL); +EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddStatusMenuItem(TMO_MenuItem *pmi, const char *pszProto = nullptr); // the status menu is about to be built // wParam = lParam = 0 @@ -121,7 +121,7 @@ EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddStatusMenuItem(TMO_MenuItem *pmi, const c // adds an item to status or main menu, according to the option -EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddProtoMenuItem(TMO_MenuItem *pmi, const char *pszProto = NULL); +EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddProtoMenuItem(TMO_MenuItem *pmi, const char *pszProto = nullptr); ///////////////////////////////////////////////////////////////////////////////////////// // GROUP MENU @@ -139,7 +139,7 @@ EXTERN_C MIR_APP_DLL(HMENU) Menu_BuildGroupMenu(void); // adds a new item to the Group menus -EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddGroupMenuItem(TMO_MenuItem *pmi, GroupMenuParam *gmp = NULL); +EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddGroupMenuItem(TMO_MenuItem *pmi, GroupMenuParam *gmp = nullptr); // the Group menu is about to be built // wParam = lParam = 0 @@ -158,7 +158,7 @@ EXTERN_C MIR_APP_DLL(HMENU) Menu_BuildSubGroupMenu(struct ClcGroup *group); // wParam=GroupMenuParam*, params to call when exec menuitem // lParam=(LPARAM)(TMO_MenuItem*)&mi -EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddSubGroupMenuItem(TMO_MenuItem *pmi, GroupMenuParam *gmp = NULL); +EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddSubGroupMenuItem(TMO_MenuItem *pmi, GroupMenuParam *gmp = nullptr); // the SubGroup menu is about to be built // wParam = lParam = 0 @@ -402,7 +402,7 @@ EXTERN_C MIR_APP_DLL(int) Clist_GroupRename(MGROUP hGroup, const wchar_t *ptszNe #define GROUPF_EXPANDED 0x04 #define GROUPF_HIDEOFFLINE 0x08 -EXTERN_C MIR_APP_DLL(wchar_t*) Clist_GroupGetName(MGROUP hGroup, DWORD *pdwFlags = NULL); +EXTERN_C MIR_APP_DLL(wchar_t*) Clist_GroupGetName(MGROUP hGroup, DWORD *pdwFlags = nullptr); ///////////////////////////////////////////////////////////////////////////////////////// // change the expanded state flag for a group internally diff --git a/include/m_contacts.h b/include/m_contacts.h index f976f4f789..779582878f 100644 --- a/include/m_contacts.h +++ b/include/m_contacts.h @@ -77,7 +77,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. EXTERN_C MIR_APP_DLL(wchar_t*) Contact_GetInfo( int type, // one of the CNF_* constants MCONTACT hContact, // contact id or NULL for the global data - const char *szProto = NULL); // protocol for global data. if skipped, grabbed from hContact + const char *szProto = nullptr); // protocol for global data. if skipped, grabbed from hContact ///////////////////////////////////////////////////////////////////////////////////////// // Add contact's dialog diff --git a/include/m_core.h b/include/m_core.h index 662912988a..f39e711750 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -172,8 +172,8 @@ typedef struct tagIconItemT IconItemT; #if defined( __cplusplus ) -MIR_CORE_DLL(void) Icon_Register(HINSTANCE hInst, const char* szSection, IconItem* pIcons, size_t iCount, char *prefix = NULL, int = hLangpack); -MIR_CORE_DLL(void) Icon_RegisterT(HINSTANCE hInst, const wchar_t* szSection, IconItemT* pIcons, size_t iCount, char *prefix = NULL, int = hLangpack); +MIR_CORE_DLL(void) Icon_Register(HINSTANCE hInst, const char* szSection, IconItem* pIcons, size_t iCount, char *prefix = nullptr, int = hLangpack); +MIR_CORE_DLL(void) Icon_RegisterT(HINSTANCE hInst, const wchar_t* szSection, IconItemT* pIcons, size_t iCount, char *prefix = nullptr, int = hLangpack); #else MIR_CORE_DLL(void) Icon_Register(HINSTANCE hInst, const char* szSection, IconItem* pIcons, size_t iCount, char *prefix, int hLangpack); MIR_CORE_DLL(void) Icon_RegisterT(HINSTANCE hInst, const wchar_t* szSection, IconItemT* pIcons, size_t iCount, char *prefix, int hLangpack); @@ -187,7 +187,7 @@ MIR_CORE_DLL(unsigned int) mir_hash(const void * key, unsigned int len); #pragma optimize("gt", on) __forceinline unsigned int mir_hashstr(const char * key) { - if (key == NULL) return 0; + if (key == nullptr) return 0; else { unsigned int len = (unsigned int)strlen((const char*)key); return mir_hash(key, len); @@ -195,7 +195,7 @@ __forceinline unsigned int mir_hashstr(const char * key) __forceinline unsigned int mir_hashstrW(const wchar_t * key) { - if (key == NULL) return 0; + if (key == nullptr) return 0; else { unsigned int len = (unsigned int)wcslen((const wchar_t*)key); return mir_hash(key, len * sizeof(wchar_t)); @@ -348,7 +348,7 @@ MIR_APP_DLL(int) ProtoGetAvatarFormatByMimeType(const wchar_t *pwszMimeType); // returns the image format and extension by the first bytes of picture // ptszExtension might be NULL #if defined( __cplusplus ) - MIR_APP_DLL(int) ProtoGetBufferFormat(const void *buf, const wchar_t **ptszExtension = NULL); + MIR_APP_DLL(int) ProtoGetBufferFormat(const void *buf, const wchar_t **ptszExtension = nullptr); #else MIR_APP_DLL(int) ProtoGetBufferFormat(const void *buf, const wchar_t **ptszExtension); #endif @@ -467,7 +467,7 @@ typedef unsigned (__stdcall *pThreadFuncEx)(void *param); typedef unsigned (__cdecl *pThreadFuncOwner)(void *owner, void *param); #if defined( __cplusplus ) - MIR_CORE_DLL(INT_PTR) Thread_Push(HINSTANCE hInst, void* pOwner = NULL); + MIR_CORE_DLL(INT_PTR) Thread_Push(HINSTANCE hInst, void* pOwner = nullptr); #else MIR_CORE_DLL(INT_PTR) Thread_Push(HINSTANCE hInst, void* pOwner); #endif @@ -475,9 +475,9 @@ MIR_CORE_DLL(INT_PTR) Thread_Pop(void); MIR_CORE_DLL(void) Thread_Wait(void); #if defined( __cplusplus ) -MIR_CORE_DLL(HANDLE) mir_forkthread(pThreadFunc aFunc, void *arg = NULL); -MIR_CORE_DLL(HANDLE) mir_forkthreadex(pThreadFuncEx aFunc, void *arg = NULL, unsigned *pThreadID = NULL); -MIR_CORE_DLL(HANDLE) mir_forkthreadowner(pThreadFuncOwner aFunc, void *owner, void *arg = NULL, unsigned *pThreadID = NULL); +MIR_CORE_DLL(HANDLE) mir_forkthread(pThreadFunc aFunc, void *arg = nullptr); +MIR_CORE_DLL(HANDLE) mir_forkthreadex(pThreadFuncEx aFunc, void *arg = nullptr, unsigned *pThreadID = nullptr); +MIR_CORE_DLL(HANDLE) mir_forkthreadowner(pThreadFuncOwner aFunc, void *owner, void *arg = nullptr, unsigned *pThreadID = nullptr); #else MIR_CORE_DLL(HANDLE) mir_forkthread(pThreadFunc aFunc, void *arg); MIR_CORE_DLL(HANDLE) mir_forkthreadex(pThreadFuncEx aFunc, void *arg, unsigned *pThreadID); @@ -516,7 +516,7 @@ MIR_CORE_DLL(BOOL) Utf8CheckString(const char* str); __forceinline char* mir_utf8decodeA(const char* src) { char *tmp = mir_strdup(src); - mir_utf8decode(tmp, NULL); + mir_utf8decode(tmp, nullptr); return tmp; } diff --git a/include/m_database.h b/include/m_database.h index 9cd38c1273..41ce36bef5 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -208,7 +208,7 @@ are no contacts in the db. */ #if defined(__cplusplus) -EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto = NULL); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto = nullptr); #else EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_first(const char *szProto); #endif @@ -222,7 +222,7 @@ hContact was the last contact in the db or hContact was invalid. */ #if defined(__cplusplus) -EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto = NULL); +EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto = nullptr); #else EXTERN_C MIR_CORE_DLL(MCONTACT) db_find_next(MCONTACT hContact, const char *szProto); #endif diff --git a/include/m_db_int.h b/include/m_db_int.h index 5885e6f015..fd10999153 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -88,8 +88,8 @@ interface MIR_APP_EXPORT MIDatabase STDMETHOD_(void, SetCacheSafetyMode)(BOOL) PURE; STDMETHOD_(LONG, GetContactCount)(void) PURE; - STDMETHOD_(MCONTACT, FindFirstContact)(const char *szProto = NULL) PURE; - STDMETHOD_(MCONTACT, FindNextContact)(MCONTACT contactID, const char *szProto = NULL) PURE; + STDMETHOD_(MCONTACT, FindFirstContact)(const char *szProto = nullptr) PURE; + STDMETHOD_(MCONTACT, FindNextContact)(MCONTACT contactID, const char *szProto = nullptr) PURE; STDMETHOD_(LONG, DeleteContact)(MCONTACT contactID) PURE; STDMETHOD_(MCONTACT, AddContact)(void) PURE; diff --git a/include/m_extraicons.h b/include/m_extraicons.h index 2ec4feaf0a..8611a02e6c 100644 --- a/include/m_extraicons.h +++ b/include/m_extraicons.h @@ -110,10 +110,10 @@ EXTERN_C MIR_APP_DLL(void) KillModuleExtraIcons(int hLangpack); #define EIF_DISABLED_BY_DEFAULT 0x0001 EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, const char *descIcon, - MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = 0, int flags = 0, int = hLangpack); + MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick = nullptr, LPARAM onClickParam = 0, int flags = 0, int = hLangpack); -EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon = NULL, - MIRANDAHOOKPARAM OnClick = NULL, LPARAM onClickParam = 0, int flags = 0, int = hLangpack); +EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon = nullptr, + MIRANDAHOOKPARAM OnClick = nullptr, LPARAM onClickParam = 0, int flags = 0, int = hLangpack); ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/m_genmenu.h b/include/m_genmenu.h index 01e8c60da7..33a56e2daa 100644 --- a/include/m_genmenu.h +++ b/include/m_genmenu.h @@ -118,7 +118,7 @@ EXTERN_C MIR_APP_DLL(HGENMENU) Menu_AddItem(int hMenuObject, TMO_MenuItem *pItem // Adds new submenu // Returns HGENMENU on success, or NULL on failure -EXTERN_C MIR_APP_DLL(HGENMENU) Menu_CreateRoot(int hMenuObject, LPCWSTR ptszName, int position, HANDLE hIcoLib = NULL, int hLang = hLangpack); +EXTERN_C MIR_APP_DLL(HGENMENU) Menu_CreateRoot(int hMenuObject, LPCWSTR ptszName, int position, HANDLE hIcoLib = nullptr, int hLang = hLangpack); ///////////////////////////////////////////////////////////////////////////////////////// // process a WM_DRAWITEM message for user context menus v0.1.1.0+ diff --git a/include/m_gui.h b/include/m_gui.h index 45b6130122..0a1dfc2025 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -259,7 +259,7 @@ struct CCallbackImp }; public: - __inline CCallbackImp(): m_object(NULL), m_func(NULL) {} + __inline CCallbackImp(): m_object(nullptr), m_func(nullptr) {} __inline CCallbackImp(const CCallbackImp &other): m_object(other.m_object), m_func(other.m_func) {} __inline CCallbackImp &operator=(const CCallbackImp &other) { m_object = other.m_object; m_func = other.m_func; return *this; } @@ -362,7 +362,7 @@ public: __forceinline DWORD LoadInt() { return (DWORD)(T)*m_option; } __forceinline void SaveInt(DWORD value) { *m_option = (T)value; } - __forceinline wchar_t* LoadText() { return NULL; } + __forceinline wchar_t* LoadText() { return nullptr; } __forceinline void SaveText(wchar_t*) {} }; @@ -1453,7 +1453,7 @@ protected: virtual void OnProtoCheckOnline(WPARAM, LPARAM); private: - void UpdateProtoTitle(const wchar_t *szText = NULL); + void UpdateProtoTitle(const wchar_t *szText = nullptr); void UpdateStatusBar(); }; diff --git a/include/m_jabber.h b/include/m_jabber.h index 58ff47b78a..a89f873a2b 100644 --- a/include/m_jabber.h +++ b/include/m_jabber.h @@ -124,21 +124,21 @@ struct IJabberInterface // Registers incoming handler. Returns handler handle on success or NULL on error. - virtual HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT) = 0; + virtual HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0; // Registers incoming handler for messages of types specified by iMsgTypes. iMsgTypes is a combination of JABBER_MESSAGE_TYPE_* flags. Returns handler handle on success or NULL on error. - virtual HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT) = 0; + virtual HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0; // Registers incoming handler. iIqTypes is a combination of JABBER_IQ_TYPE_* flags. Returns handler handle on success or NULL on error. - virtual HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT) = 0; + virtual HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0; // Registers temporary handler for incoming stanza of type iIqType with id iIqId. iIqTypes is a combination of JABBER_IQ_TYPE_* flags. Returns handler handle on success or NULL on error. // If dwTimeout milliseconds pass and no Iq stanza with the specified iIqId is received, Jabber plugin will call Func() with NULL node. - virtual HJHANDLER STDMETHODCALLTYPE AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData = NULL, DWORD dwTimeout = 30000, int iPriority = JH_PRIORITY_DEFAULT) = 0; + virtual HJHANDLER STDMETHODCALLTYPE AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData = nullptr, DWORD dwTimeout = 30000, int iPriority = JH_PRIORITY_DEFAULT) = 0; // Registers handler for outgoing nodes. Returns handler handle on success or NULL on error. // Return FALSE in the handler to continue, or TRUE to abort sending. - virtual HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT) = 0; + virtual HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0; // Unregisters handler by its handle. virtual int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler) = 0; diff --git a/include/m_json.h b/include/m_json.h index ed4de56c37..9df72cd305 100644 --- a/include/m_json.h +++ b/include/m_json.h @@ -135,7 +135,7 @@ class JSONROOT JSONNode *m_node; public: - __forceinline JSONROOT() { m_node = NULL; } + __forceinline JSONROOT() { m_node = nullptr; } __forceinline JSONROOT(LPCSTR text) { Parse(text); } __forceinline ~JSONROOT() { json_delete(m_node); } diff --git a/include/m_netlib.h b/include/m_netlib.h index 4bc5dc01be..10fa59eb31 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -726,7 +726,7 @@ EXTERN_C MIR_APP_DLL(int) Netlib_LogfW(HNETLIBUSER hUser, const wchar_t *fmt, .. // Returns HANDLE = NULL on error or non-null value on success // Known providers: Basic, NTLM, Negotiate, Kerberos, GSSAPI - (Kerberos SASL) -EXTERN_C MIR_APP_DLL(HANDLE) Netlib_InitSecurityProvider(const wchar_t *szProviderName, const wchar_t *szPrincipal = NULL); +EXTERN_C MIR_APP_DLL(HANDLE) Netlib_InitSecurityProvider(const wchar_t *szProviderName, const wchar_t *szPrincipal = nullptr); ///////////////////////////////////////////////////////////////////////////////////////// // Destroys a security provider's handle, provided by Netlib_InitSecurityProvider. diff --git a/include/m_options.h b/include/m_options.h index f54314ae8e..cdf89a9115 100644 --- a/include/m_options.h +++ b/include/m_options.h @@ -95,9 +95,9 @@ EXTERN_C MIR_APP_DLL(void) KillModuleOptions(int _hLang); // Opens the options dialog, optionally at the specified page // Returns 0 on success, nonzero on failure -EXTERN_C MIR_APP_DLL(int) Options_Open(const wchar_t *pszGroup, const wchar_t *pszPage = NULL, const wchar_t *pszTab = NULL, int = hLangpack); +EXTERN_C MIR_APP_DLL(int) Options_Open(const wchar_t *pszGroup, const wchar_t *pszPage = nullptr, const wchar_t *pszTab = nullptr, int = hLangpack); // Opens the options dialog, with only specified page -EXTERN_C MIR_APP_DLL(HWND) Options_OpenPage(const wchar_t *pszGroup, const wchar_t *pszPage = NULL, const wchar_t *pszTab = NULL, int = hLangpack); +EXTERN_C MIR_APP_DLL(HWND) Options_OpenPage(const wchar_t *pszGroup, const wchar_t *pszPage = nullptr, const wchar_t *pszTab = nullptr, int = hLangpack); #endif //M_OPTIONS_H__ diff --git a/include/m_popup.h b/include/m_popup.h index 1c1342295e..509a6f20f4 100644 --- a/include/m_popup.h +++ b/include/m_popup.h @@ -287,7 +287,7 @@ and it will work. Just look at the example I've written above (PopupDlgProc). */ #define MS_POPUP_GETPLUGINDATA "Popup/GetPluginData" static void __inline * PUGetPluginData(HWND hPopupWindow) { - long * uselessPointer = NULL; + long * uselessPointer = nullptr; return (void*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hPopupWindow, (LPARAM)uselessPointer); } @@ -667,7 +667,7 @@ typedef struct { HANDLE __forceinline Popup_RegisterClass(POPUPCLASS *pc) { if (!ServiceExists(MS_POPUP_REGISTERCLASS)) - return NULL; + return nullptr; return (HANDLE)CallService(MS_POPUP_REGISTERCLASS, 0, LPARAM(pc)); } diff --git a/include/m_string.h b/include/m_string.h index c7dee400e0..1077298bcb 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -626,13 +626,13 @@ public: static int __stdcall GetBaseTypeLength(LPCSTR pszSrc) { // Returns required buffer size in wchar_ts - return ::MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, NULL, 0)-1; + return ::MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, nullptr, 0)-1; } static int __stdcall GetBaseTypeLength(LPCSTR pszSrc, int nLength) { // Returns required buffer size in wchar_ts - return ::MultiByteToWideChar(CP_ACP, 0, pszSrc, nLength, NULL, 0); + return ::MultiByteToWideChar(CP_ACP, 0, pszSrc, nLength, nullptr, 0); } static int __stdcall GetBaseTypeLength(LPCWSTR pszSrc) @@ -677,13 +677,13 @@ public: static int __stdcall SafeStringLen(LPCSTR psz) { // returns length in bytes - return (psz != NULL) ? (int)strlen(psz) : 0; + return (psz != nullptr) ? (int)strlen(psz) : 0; } static int __stdcall SafeStringLen(LPCWSTR psz) { // returns length in wchar_ts - return (psz != NULL) ? (int)wcslen(psz) : 0; + return (psz != nullptr) ? (int)wcslen(psz) : 0; } static int __stdcall GetCharLen(const wchar_t* pch) diff --git a/include/m_string.inl b/include/m_string.inl index 33acc46c64..97b94040b9 100644 --- a/include/m_string.inl +++ b/include/m_string.inl @@ -45,7 +45,7 @@ CMSimpleStringT::CMSimpleStringT(PCXSTR pszSrc) { int nLength = StringLength(pszSrc); CMStringData* pData = mirstr_allocate(nLength, sizeof(XCHAR)); - if (pData != NULL) { + if (pData != nullptr) { Attach(pData); SetLength(nLength); CopyChars(m_pszData, nLength, pszSrc, nLength); @@ -56,7 +56,7 @@ template CMSimpleStringT::CMSimpleStringT(const XCHAR* pchSrc, int nLength) { CMStringData* pData = mirstr_allocate(nLength, sizeof(XCHAR)); - if (pData != NULL) { + if (pData != nullptr) { Attach(pData); SetLength(nLength); CopyChars(m_pszData, nLength, pchSrc, nLength); @@ -165,7 +165,7 @@ void CMSimpleStringT::FreeExtra() if (!pOldData->IsLocked()) { // Don't reallocate a locked buffer that's shrinking CMStringData* pNewData = mirstr_allocate(nLength, sizeof(XCHAR)); - if (pNewData == NULL) { + if (pNewData == nullptr) { SetLength(nLength); return; } @@ -326,7 +326,7 @@ void __stdcall CMSimpleStringT::CopyCharsOverlapped(XCHAR* pchDest, si template int __stdcall CMSimpleStringT::StringLength(const char* psz) { - if (psz == NULL) + if (psz == nullptr) return(0); return (int(strlen(psz))); @@ -335,7 +335,7 @@ int __stdcall CMSimpleStringT::StringLength(const char* psz) template int __stdcall CMSimpleStringT::StringLength(const wchar_t* psz) { - if (psz == NULL) + if (psz == nullptr) return 0; return int(wcslen(psz)); @@ -344,7 +344,7 @@ int __stdcall CMSimpleStringT::StringLength(const wchar_t* psz) template int __stdcall CMSimpleStringT::StringLengthN(const char* psz, size_t sizeInXChar) { - if (psz == NULL) + if (psz == nullptr) return 0; return int(strnlen(psz, sizeInXChar)); @@ -353,7 +353,7 @@ int __stdcall CMSimpleStringT::StringLengthN(const char* psz, size_t s template int __stdcall CMSimpleStringT::StringLengthN(const wchar_t* psz, size_t sizeInXChar) { - if (psz == NULL) + if (psz == nullptr) return 0; return int(wcsnlen(psz, sizeInXChar)); @@ -381,7 +381,7 @@ void CMSimpleStringT::Fork(int nLength) CMStringData* pOldData = GetData(); int nOldLength = pOldData->nDataLength; CMStringData* pNewData = mirstr_allocate(nLength, sizeof(XCHAR)); - if (pNewData != NULL) { + if (pNewData != nullptr) { int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength) + 1; // Copy '\0' CopyChars(PXSTR(pNewData->data()), nCharsToCopy, PCXSTR(pOldData->data()), nCharsToCopy); pNewData->nDataLength = nOldLength; @@ -435,7 +435,7 @@ void CMSimpleStringT::Reallocate(int nLength) return; CMStringData* pNewData = mirstr_realloc(pOldData, nLength, sizeof(XCHAR)); - if (pNewData != NULL) + if (pNewData != nullptr) Attach(pNewData); } @@ -449,7 +449,7 @@ void CMSimpleStringT::SetLength(int nLength) template CMStringData* __stdcall CMSimpleStringT::CloneData(CMStringData* pData) { - CMStringData* pNewData = NULL; + CMStringData* pNewData = nullptr; if (!pData->IsLocked()) { pNewData = pData; @@ -588,7 +588,7 @@ template< typename BaseType, class StringTraits > CMStringT& CMStringT::operator=(PCYSTR pszSrc) { // nDestLength is in XCHARs - int nDestLength = (pszSrc != NULL) ? StringTraits::GetBaseTypeLength(pszSrc) : 0; + int nDestLength = (pszSrc != nullptr) ? StringTraits::GetBaseTypeLength(pszSrc) : 0; if (nDestLength > 0) { PXSTR pszBuffer = this->GetBuffer(nDestLength); StringTraits::ConvertToBaseType(pszBuffer, nDestLength, pszSrc); @@ -836,7 +836,7 @@ int CMStringT::Replace(PCXSTR pszOld, PCXSTR pszNew) PCXSTR pszEnd = pszStart + this->GetLength(); while (pszStart < pszEnd) { PCXSTR pszTarget; - while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != NULL) { + while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != nullptr) { nCount++; pszStart = pszTarget + nSourceLen; } @@ -859,7 +859,7 @@ int CMStringT::Replace(PCXSTR pszOld, PCXSTR pszNew) // loop again to actually do the work while (pszStart < pszEnd) { PXSTR pszTarget; - while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != NULL) { + while ((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != nullptr) { int nBalance = nOldLength - int(pszTarget - pszBuffer + nSourceLen); memmove_s(pszTarget + nReplacementLen, nBalance*sizeof(XCHAR), pszTarget + nSourceLen, nBalance*sizeof(XCHAR)); @@ -913,7 +913,7 @@ int CMStringT::Remove(XCHAR chRemove) template< typename BaseType, class StringTraits > CMStringT CMStringT::Tokenize(PCXSTR pszTokens, int& iStart) const { - if ((pszTokens == NULL) || (*pszTokens == (XCHAR)0)) { + if ((pszTokens == nullptr) || (*pszTokens == (XCHAR)0)) { if (iStart < this->GetLength()) return CMStringT(this->GetString() + iStart); } @@ -957,7 +957,7 @@ int CMStringT::Find(XCHAR ch, int iStart = 0) const PCXSTR psz = StringTraits::StringFindChar(this->GetString() + iStart, ch); // return -1 if not found and index otherwise - return (psz == NULL) ? -1 : int(psz - this->GetString()); + return (psz == nullptr) ? -1 : int(psz - this->GetString()); } // look for a specific sub-string @@ -967,7 +967,7 @@ template< typename BaseType, class StringTraits > int CMStringT::Find(PCXSTR pszSub, int iStart = 0) const { // iStart is in XCHARs - if (pszSub == NULL) + if (pszSub == nullptr) return -1; // nLength is in XCHARs @@ -979,7 +979,7 @@ int CMStringT::Find(PCXSTR pszSub, int iStart = 0) const PCXSTR psz = StringTraits::StringFindString(this->GetString() + iStart, pszSub); // return -1 for not found, distance from beginning otherwise - return (psz == NULL) ? -1 : int(psz - this->GetString()); + return (psz == nullptr) ? -1 : int(psz - this->GetString()); } // Find the first occurrence of any of the characters in string 'pszCharSet' @@ -987,7 +987,7 @@ template< typename BaseType, class StringTraits > int CMStringT::FindOneOf(PCXSTR pszCharSet) const { PCXSTR psz = StringTraits::StringScanSet(this->GetString(), pszCharSet); - return (psz == NULL) ? -1 : int(psz - this->GetString()); + return (psz == nullptr) ? -1 : int(psz - this->GetString()); } // Find the last occurrence of character 'ch' @@ -998,7 +998,7 @@ int CMStringT::ReverseFind(XCHAR ch) const PCXSTR psz = StringTraits::StringFindCharRev(this->GetString(), ch); // return -1 if not found, distance from beginning otherwise - return (psz == NULL) ? -1 : int(psz - this->GetString()); + return (psz == nullptr) ? -1 : int(psz - this->GetString()); } // manipulation @@ -1049,19 +1049,19 @@ CMStringT& CMStringT::TrimRight( // at beginning (DBCS aware) PCXSTR psz = this->GetString(); - PCXSTR pszLast = NULL; + PCXSTR pszLast = nullptr; while (*psz != 0) { if (StringTraits::IsSpace(*psz)) { - if (pszLast == NULL) + if (pszLast == nullptr) pszLast = psz; } - else pszLast = NULL; + else pszLast = nullptr; psz = StringTraits::CharNext(psz); } - if (pszLast != NULL) { + if (pszLast != nullptr) { // truncate at trailing space start int iLast = int(pszLast - this->GetString()); @@ -1126,19 +1126,19 @@ CMStringT& CMStringT::TrimRight( // by starting at beginning (DBCS aware) PCXSTR psz = this->GetString(); - PCXSTR pszLast = NULL; + PCXSTR pszLast = nullptr; while (*psz != 0) { if (*psz == chTarget) { - if (pszLast == NULL) + if (pszLast == nullptr) pszLast = psz; } - else pszLast = NULL; + else pszLast = nullptr; psz = StringTraits::CharNext(psz); } - if (pszLast != NULL) { + if (pszLast != nullptr) { // truncate at left-most matching character int iLast = int(pszLast - this->GetString()); this->Truncate(iLast); @@ -1152,7 +1152,7 @@ template< typename BaseType, class StringTraits > CMStringT& CMStringT::TrimRight(PCXSTR pszTargets) { // if we're not trimming anything, we're not doing any work - if ((pszTargets == NULL) || (*pszTargets == 0)) { + if ((pszTargets == nullptr) || (*pszTargets == 0)) { return *this; } @@ -1160,21 +1160,21 @@ CMStringT& CMStringT::TrimRight( // by starting at beginning (DBCS aware) PCXSTR psz = this->GetString(); - PCXSTR pszLast = NULL; + PCXSTR pszLast = nullptr; while (*psz != 0) { - if (StringTraits::StringFindChar(pszTargets, *psz) != NULL) { - if (pszLast == NULL) { + if (StringTraits::StringFindChar(pszTargets, *psz) != nullptr) { + if (pszLast == nullptr) { pszLast = psz; } } else { - pszLast = NULL; + pszLast = nullptr; } psz = StringTraits::CharNext(psz); } - if (pszLast != NULL) { + if (pszLast != nullptr) { // truncate at left-most matching character int iLast = int(pszLast - this->GetString()); this->Truncate(iLast); @@ -1213,12 +1213,12 @@ template< typename BaseType, class StringTraits > CMStringT& CMStringT::TrimLeft(PCXSTR pszTargets) { // if we're not trimming anything, we're not doing any work - if ((pszTargets == NULL) || (*pszTargets == 0)) { + if ((pszTargets == nullptr) || (*pszTargets == 0)) { return *this; } PCXSTR psz = this->GetString(); - while ((*psz != 0) && (StringTraits::StringFindChar(pszTargets, *psz) != NULL)) { + while ((*psz != 0) && (StringTraits::StringFindChar(pszTargets, *psz) != nullptr)) { psz = StringTraits::CharNext(psz); } @@ -1380,7 +1380,7 @@ typename CMStringT::PCXSTR CMStringT BOOL CMStringT::GetEnvironmentVariable(PCXSTR pszVar) { - ULONG nLength = StringTraits::GetEnvironmentVariable(pszVar, NULL, 0); + ULONG nLength = StringTraits::GetEnvironmentVariable(pszVar, nullptr, 0); BOOL bRetVal = FALSE; if (nLength == 0) diff --git a/include/m_system.h b/include/m_system.h index a2f877e085..cc3be9a6bf 100644 --- a/include/m_system.h +++ b/include/m_system.h @@ -93,7 +93,7 @@ EXTERN_C MIR_APP_DLL(void) Miranda_GetVersionText(char *pDest, size_t cbSize); // when a handle gets triggered, an appopriate stub gets called typedef void (CALLBACK *MWaitableStub)(void); -EXTERN_C MIR_APP_DLL(void) Miranda_WaitOnHandle(MWaitableStub pFunc, HANDLE hEvent = NULL); +EXTERN_C MIR_APP_DLL(void) Miranda_WaitOnHandle(MWaitableStub pFunc, HANDLE hEvent = nullptr); // wParam = 0 (ignored) // lParam = 0 (ignored) diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 500dd1d3c2..eed0bcc8e6 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -41,7 +41,7 @@ protected: T* data; public: - __inline explicit mir_ptr() : data(NULL) {} + __inline explicit mir_ptr() : data(nullptr) {} __inline explicit mir_ptr(T *_p) : data(_p) {} __inline ~mir_ptr() { mir_free(data); } __inline T* get() const { return data; } @@ -49,7 +49,7 @@ public: __inline T* operator->() const { return data; } __inline operator T*() const { return data; } __inline operator INT_PTR() const { return (INT_PTR)data; } - __inline T* detach() { T *res = data; data = NULL; return res; } + __inline T* detach() { T *res = data; data = nullptr; return res; } }; typedef mir_ptr ptrA; @@ -133,10 +133,13 @@ class MZeroedObject { public: __inline void* operator new( size_t size ) - { return calloc( 1, size ); + { + return calloc( 1, size ); } + __inline void operator delete( void* p ) - { free( p ); + { + free( p ); } }; @@ -151,21 +154,23 @@ template struct LIST { typedef int (*FTSortFunc)(const T* p1, const T* p2); - __inline LIST(int aincr, FTSortFunc afunc = NULL) - { memset(this, 0, sizeof(*this)); + __inline LIST(int aincr, FTSortFunc afunc = nullptr) + { + memset(this, 0, sizeof(*this)); increment = aincr; sortFunc = afunc; } __inline LIST(int aincr, INT_PTR id) - { memset(this, 0, sizeof(*this)); + { + memset(this, 0, sizeof(*this)); increment = aincr; sortFunc = FTSortFunc(id); } __inline LIST(const LIST& x) { - items = NULL; + items = nullptr; List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T)); } @@ -181,12 +186,13 @@ template struct LIST destroy(); } - __inline T* operator[](int idx) const { return (idx >= 0 && idx < count) ? items[idx] : NULL; } + __inline T* operator[](int idx) const { return (idx >= 0 && idx < count) ? items[idx] : nullptr; } __inline int getCount(void) const { return count; } __inline T** getArray(void) const { return items; } __inline int getIndex(T *p) const - { int idx; + { + int idx; return (!List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx; } @@ -214,7 +220,7 @@ template struct OBJLIST : public LIST { typedef int (*FTSortFunc)(const T* p1, const T* p2); - __inline OBJLIST(int aincr, FTSortFunc afunc = NULL) : + __inline OBJLIST(int aincr, FTSortFunc afunc = nullptr) : LIST(aincr, afunc) {} @@ -224,12 +230,14 @@ template struct OBJLIST : public LIST __inline OBJLIST(const OBJLIST& x) : LIST(x.increment, x.sortFunc) - { this->items = NULL; + { + this->items = nullptr; List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T)); } __inline OBJLIST& operator = (const OBJLIST& x) - { destroy(); + { + destroy(); List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T)); return *this; } diff --git a/include/m_timezones.h b/include/m_timezones.h index a45471fa7a..57ff780cd6 100644 --- a/include/m_timezones.h +++ b/include/m_timezones.h @@ -64,27 +64,27 @@ EXTERN_C MIR_CORE_DLL(LPCTSTR) TimeZone_GetDescription(LPCTSTR TZname); __forceinline int printDateTimeByContact (MCONTACT hContact, LPCTSTR szFormat, LPTSTR szDest, int cbDest, DWORD dwFlags) { - return TimeZone_PrintDateTime(TimeZone_CreateByContact(hContact, 0, dwFlags), szFormat, szDest, cbDest, dwFlags); + return TimeZone_PrintDateTime(TimeZone_CreateByContact(hContact, nullptr, dwFlags), szFormat, szDest, cbDest, dwFlags); } __forceinline int printTimeStampByContact(MCONTACT hContact, mir_time ts, LPCTSTR szFormat, LPTSTR szDest, int cbDest, DWORD dwFlags) { - return TimeZone_PrintTimeStamp(TimeZone_CreateByContact(hContact, 0, dwFlags), ts, szFormat, szDest, cbDest, dwFlags); + return TimeZone_PrintTimeStamp(TimeZone_CreateByContact(hContact, nullptr, dwFlags), ts, szFormat, szDest, cbDest, dwFlags); } __forceinline LPTIME_ZONE_INFORMATION getTziByContact(MCONTACT hContact) { - return TimeZone_GetInfo(TimeZone_CreateByContact(hContact, 0, 0)); + return TimeZone_GetInfo(TimeZone_CreateByContact(hContact, nullptr, 0)); } __forceinline int getTimeZoneTimeByContact(MCONTACT hContact, SYSTEMTIME *st) { - return TimeZone_GetTimeZoneTime(TimeZone_CreateByContact(hContact, 0, 0), st); + return TimeZone_GetTimeZoneTime(TimeZone_CreateByContact(hContact, nullptr, 0), st); } __forceinline mir_time timeStampToTimeZoneTimeStampByContact(MCONTACT hContact, mir_time ts) { - return TimeZone_UtcToLocal(TimeZone_CreateByContact(hContact, 0, 0), ts); + return TimeZone_UtcToLocal(TimeZone_CreateByContact(hContact, nullptr, 0), ts); } #endif diff --git a/include/m_utils.h b/include/m_utils.h index 13de0e6ffd..bd07c2ac9e 100644 --- a/include/m_utils.h +++ b/include/m_utils.h @@ -254,8 +254,8 @@ EXTERN_C MIR_CORE_DLL(void) Bitmap_GetFilter(wchar_t *dest, size_t destLen); // Returns number of chars copied. #if defined( __cplusplus ) -EXTERN_C MIR_CORE_DLL(int) PathToRelative(const char *pszSrc, char *pszOut, const char* pszBase = 0); -EXTERN_C MIR_CORE_DLL(int) PathToRelativeW(const wchar_t *pwszSrc, wchar_t *pwszOut, const wchar_t* pwszBase = 0); +EXTERN_C MIR_CORE_DLL(int) PathToRelative(const char *pszSrc, char *pszOut, const char* pszBase = nullptr); +EXTERN_C MIR_CORE_DLL(int) PathToRelativeW(const wchar_t *pwszSrc, wchar_t *pwszOut, const wchar_t* pwszBase = nullptr); #else EXTERN_C MIR_CORE_DLL(int) PathToRelative(const char *pszSrc, char *pszOut, const char* pszBase); EXTERN_C MIR_CORE_DLL(int) PathToRelativeW(const wchar_t *pwszSrc, wchar_t *pwszOut, const wchar_t* pwszBase); @@ -273,8 +273,8 @@ EXTERN_C MIR_CORE_DLL(int) PathToRelativeW(const wchar_t *pwszSrc, wchar_t *pwsz // Returns numbers of chars copied. #if defined( __cplusplus ) -EXTERN_C MIR_CORE_DLL(int) PathToAbsolute(const char *pszSrc, char *pszOut, const char* pszBase = 0); -EXTERN_C MIR_CORE_DLL(int) PathToAbsoluteW(const wchar_t *pwszSrc, wchar_t *pwszOut, const wchar_t* pwszBase = 0); +EXTERN_C MIR_CORE_DLL(int) PathToAbsolute(const char *pszSrc, char *pszOut, const char* pszBase = nullptr); +EXTERN_C MIR_CORE_DLL(int) PathToAbsoluteW(const wchar_t *pwszSrc, wchar_t *pwszOut, const wchar_t* pwszBase = nullptr); #else EXTERN_C MIR_CORE_DLL(int) PathToAbsolute(const char *pszSrc, char *pszOut, const char* pszBase); EXTERN_C MIR_CORE_DLL(int) PathToAbsoluteW(const wchar_t *pwszSrc, wchar_t *pwszOut, const wchar_t* pwszBase); @@ -353,8 +353,8 @@ struct REPLACEVARSARRAY MAllStrings key, value; }; -EXTERN_C MIR_APP_DLL(char*) Utils_ReplaceVars(const char *szData, MCONTACT hContact = 0, REPLACEVARSARRAY *vars = NULL); -EXTERN_C MIR_APP_DLL(wchar_t*) Utils_ReplaceVarsW(const wchar_t *szData, MCONTACT hContact = 0, REPLACEVARSARRAY *vars = NULL); +EXTERN_C MIR_APP_DLL(char*) Utils_ReplaceVars(const char *szData, MCONTACT hContact = 0, REPLACEVARSARRAY *vars = nullptr); +EXTERN_C MIR_APP_DLL(wchar_t*) Utils_ReplaceVarsW(const wchar_t *szData, MCONTACT hContact = 0, REPLACEVARSARRAY *vars = nullptr); #if defined(__cplusplus) #if !defined(M_SYSTEM_CPP_H__) -- cgit v1.2.3