From 214bd6ec96e285c012e627cd9dcabb755645fe7a Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 23 Oct 2013 16:34:30 -0400 Subject: [PATCH] Bug 784739 - Switch from NULL to nullptr in dom/plugins/base/; r=ehsan --HG-- extra : rebase_source : 827cf2bb75601a723a64593fca5c0cf6632c959c --- dom/plugins/base/android/ANPAudio.cpp | 22 ++++---- dom/plugins/base/android/ANPOpenGL.cpp | 2 +- dom/plugins/base/android/ANPSurface.cpp | 10 ++-- dom/plugins/base/android/ANPSystem.cpp | 4 +- dom/plugins/base/npapi.h | 2 +- dom/plugins/base/npruntime.h | 12 ++--- dom/plugins/base/nsJSNPRuntime.cpp | 14 ++--- dom/plugins/base/nsNPAPIPlugin.cpp | 30 ++++++----- dom/plugins/base/nsNPAPIPlugin.h | 2 +- dom/plugins/base/nsNPAPIPluginInstance.cpp | 14 ++--- .../base/nsPluginDirServiceProvider.cpp | 18 +++---- dom/plugins/base/nsPluginHost.cpp | 12 ++--- dom/plugins/base/nsPluginHost.h | 12 ++--- dom/plugins/base/nsPluginInstanceOwner.cpp | 22 ++++---- dom/plugins/base/nsPluginInstanceOwner.h | 2 +- dom/plugins/base/nsPluginModule.cpp | 6 +-- dom/plugins/base/nsPluginNativeWindowGtk2.cpp | 12 ++--- dom/plugins/base/nsPluginNativeWindowOS2.cpp | 10 ++-- dom/plugins/base/nsPluginNativeWindowWin.cpp | 26 +++++----- dom/plugins/base/nsPluginsDirDarwin.cpp | 52 +++++++++++-------- dom/plugins/base/nsPluginsDirOS2.cpp | 2 +- dom/plugins/base/nsPluginsDirUnix.cpp | 16 +++--- dom/plugins/base/nsPluginsDirWin.cpp | 24 ++++----- 23 files changed, 168 insertions(+), 158 deletions(-) diff --git a/dom/plugins/base/android/ANPAudio.cpp b/dom/plugins/base/android/ANPAudio.cpp index 9ad68973306e..06c3a053a244 100644 --- a/dom/plugins/base/android/ANPAudio.cpp +++ b/dom/plugins/base/android/ANPAudio.cpp @@ -136,7 +136,7 @@ AudioRunnable::Run() return NS_ERROR_FAILURE; } - jbyte *byte = jenv->GetByteArrayElements(bytearray, NULL); + jbyte *byte = jenv->GetByteArrayElements(bytearray, nullptr); if (!byte) { LOG("AudioRunnable:: Run. Could not create bytearray"); return NS_ERROR_FAILURE; @@ -205,13 +205,13 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz void* user) { ANPAudioTrack *s = new ANPAudioTrack(); - if (s == NULL) { - return NULL; + if (s == nullptr) { + return nullptr; } JNIEnv *jenv = GetJNIForThread(); if (!jenv) - return NULL; + return nullptr; s->at_class = init_jni_bindings(jenv); s->rate = sampleRate; @@ -262,10 +262,10 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz s->bufferSize, MODE_STREAM); - if (autoFrame.CheckForException() || obj == NULL) { + if (autoFrame.CheckForException() || obj == nullptr) { jenv->DeleteGlobalRef(s->at_class); free(s); - return NULL; + return nullptr; } jint state = jenv->CallIntMethod(obj, at.getstate); @@ -273,7 +273,7 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz if (autoFrame.CheckForException() || state == STATE_UNINITIALIZED) { jenv->DeleteGlobalRef(s->at_class); free(s); - return NULL; + return nullptr; } s->output_unit = jenv->NewGlobalRef(obj); @@ -283,7 +283,7 @@ anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz void anp_audio_deleteTrack(ANPAudioTrack* s) { - if (s == NULL) { + if (s == nullptr) { return; } @@ -298,7 +298,7 @@ anp_audio_deleteTrack(ANPAudioTrack* s) void anp_audio_start(ANPAudioTrack* s) { - if (s == NULL || s->output_unit == NULL) { + if (s == nullptr || s->output_unit == nullptr) { return; } @@ -333,7 +333,7 @@ anp_audio_start(ANPAudioTrack* s) void anp_audio_pause(ANPAudioTrack* s) { - if (s == NULL || s->output_unit == NULL) { + if (s == nullptr || s->output_unit == nullptr) { return; } @@ -348,7 +348,7 @@ anp_audio_pause(ANPAudioTrack* s) void anp_audio_stop(ANPAudioTrack* s) { - if (s == NULL || s->output_unit == NULL) { + if (s == nullptr || s->output_unit == nullptr) { return; } diff --git a/dom/plugins/base/android/ANPOpenGL.cpp b/dom/plugins/base/android/ANPOpenGL.cpp index c6adff8f7623..b3cafe4e1e16 100644 --- a/dom/plugins/base/android/ANPOpenGL.cpp +++ b/dom/plugins/base/android/ANPOpenGL.cpp @@ -25,7 +25,7 @@ static ANPEGLContext anp_opengl_acquireContext(NPP instance) { GLContext* context = pinst->GLContext(); if (!context) - return NULL; + return nullptr; context->MakeCurrent(); return context->GetNativeData(GLContext::NativeGLContext); diff --git a/dom/plugins/base/android/ANPSurface.cpp b/dom/plugins/base/android/ANPSurface.cpp index a638d4c86825..b6a699f28577 100644 --- a/dom/plugins/base/android/ANPSurface.cpp +++ b/dom/plugins/base/android/ANPSurface.cpp @@ -58,7 +58,7 @@ static struct ANPSurfaceFunctions { static inline void* getSurface(JNIEnv* env, jobject view) { if (!env || !view) { - return NULL; + return nullptr; } if (!gSurfaceJavaGlue.initialized) { @@ -93,14 +93,14 @@ static inline void* getSurface(JNIEnv* env, jobject view) { if (!gSurfaceJavaGlue.surfacePointer) { LOG("Failed to acquire surface pointer"); - return NULL; + return nullptr; } env->DeleteLocalRef(surfaceClass); env->DeleteLocalRef(surfaceViewClass); env->DeleteLocalRef(surfaceHolderClass); - gSurfaceJavaGlue.initialized = (gSurfaceJavaGlue.surfacePointer != NULL); + gSurfaceJavaGlue.initialized = (gSurfaceJavaGlue.surfacePointer != nullptr); } jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder); @@ -182,7 +182,7 @@ static bool anp_surface_lock(JNIEnv* env, jobject surfaceView, ANPBitmap* bitmap return false; } - void* region = NULL; + void* region = nullptr; if (dirtyRect) { region = malloc(ANDROID_REGION_SIZE); gSurfaceFunctions.regionConstructor(region); @@ -227,7 +227,7 @@ static bool anp_surface_lock(JNIEnv* env, jobject surfaceView, ANPBitmap* bitmap if (info.w > 0 && info.h > 0) { bitmap->baseAddr = info.bits; } else { - bitmap->baseAddr = NULL; + bitmap->baseAddr = nullptr; return false; } diff --git a/dom/plugins/base/android/ANPSystem.cpp b/dom/plugins/base/android/ANPSystem.cpp index f182eb924102..098153e87bc9 100644 --- a/dom/plugins/base/android/ANPSystem.cpp +++ b/dom/plugins/base/android/ANPSystem.cpp @@ -19,8 +19,8 @@ const char* anp_system_getApplicationDataDirectory(NPP instance) { - static const char *dir = NULL; - static const char *privateDir = NULL; + static const char *dir = nullptr; + static const char *privateDir = nullptr; bool isPrivate = false; diff --git a/dom/plugins/base/npapi.h b/dom/plugins/base/npapi.h index 9259fa9afa06..02addceb537b 100644 --- a/dom/plugins/base/npapi.h +++ b/dom/plugins/base/npapi.h @@ -154,7 +154,7 @@ typedef struct _NPStream void* notifyData; const char* headers; /* Response headers from host. * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. - * Used for HTTP only; NULL for non-HTTP. + * Used for HTTP only; nullptr for non-HTTP. * Available from NPP_NewStream onwards. * Plugin should copy this data before storing it. * Includes HTTP status line and all headers, diff --git a/dom/plugins/base/npruntime.h b/dom/plugins/base/npruntime.h index 6e891650456d..31404b6e5fc8 100644 --- a/dom/plugins/base/npruntime.h +++ b/dom/plugins/base/npruntime.h @@ -137,13 +137,13 @@ void NPN_ReleaseVariantValue(NPVariant *variant); #define VOID_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Void; \ - (_v).value.objectValue = NULL; \ + (_v).value.objectValue = nullptr; \ NP_END_MACRO #define NULL_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Null; \ - (_v).value.objectValue = NULL; \ + (_v).value.objectValue = nullptr; \ NP_END_MACRO #define BOOLEAN_TO_NPVARIANT(_val, _v) \ @@ -216,7 +216,7 @@ typedef void *NPIdentifier; methods and properties can be identified by either strings or integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be compared using ==. In case of any errors, the requested - NPIdentifier(s) will be NULL. NPIdentifier lifetime is controlled + NPIdentifier(s) will be nullptr. NPIdentifier lifetime is controlled by the browser. Plugins do not need to worry about memory management with regards to NPIdentifiers. */ @@ -283,9 +283,9 @@ typedef bool (*NPConstructFunctionPtr)(NPObject *npobj, NPObject instance after the invalidate callback has been called will result in undefined behavior, even if the native code is still retaining those NPObject instances. (The runtime - will typically return immediately, with 0 or NULL, from an attempt - to dispatch to a NPObject, but this behavior should not be - depended upon.) + will typically return immediately, with 0 or nullptr, from an + attempt to dispatch to a NPObject, but this behavior should not + be depended upon.) The NPEnumerationFunctionPtr function may pass an array of NPIdentifiers back to the caller. The callee allocs the memory of diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index f76072752915..65ddd4466c26 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -1076,15 +1076,15 @@ GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true) while (obj && (obj = js::CheckedUnwrap(obj))) { if (JS_GetClass(obj) == &sNPObjectJSWrapperClass) { if (wrapResult && !JS_WrapObject(cx, &obj)) { - return NULL; + return nullptr; } return obj; } if (!::JS_GetPrototype(cx, obj, &obj)) { - return NULL; + return nullptr; } } - return NULL; + return nullptr; } static NPObject * @@ -1620,13 +1620,13 @@ NPObjWrapper_Convert(JSContext *cx, JS::Handle obj, JSType hint, JS:: if (!JS_GetProperty(cx, obj, "toString", &v)) return false; if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(v))) { - if (!JS_CallFunctionValue(cx, obj, v, 0, NULL, vp.address())) + if (!JS_CallFunctionValue(cx, obj, v, 0, nullptr, vp.address())) return false; if (JSVAL_IS_PRIMITIVE(vp)) return true; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CONVERT_TO, + JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, JS_GetClass(obj)->name, hint == JSTYPE_VOID ? "primitive type" @@ -1731,7 +1731,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj) JS::Rooted obj(cx, ((nsJSObjWrapper *)npobj)->mJSObj); if (!JS_WrapObject(cx, &obj)) { - return NULL; + return nullptr; } return obj; } @@ -1768,7 +1768,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj) // as cx, so we need to wrap it before returning it. JS::Rooted obj(cx, entry->mJSObj); if (!JS_WrapObject(cx, &obj)) { - return NULL; + return nullptr; } return obj; } diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 2b9c1ec6042b..fd6bd0ee0cfd 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -167,8 +167,8 @@ static NPNetscapeFuncs sBrowserFuncs = { _unscheduletimer, _popupcontextmenu, _convertpoint, - NULL, // handleevent, unimplemented - NULL, // unfocusinstance, unimplemented + nullptr, // handleevent, unimplemented + nullptr, // unfocusinstance, unimplemented _urlredirectresponse, _initasyncsurface, _finalizeasyncsurface, @@ -497,7 +497,7 @@ nsNPAPIPlugin::RetainStream(NPStream *pstream, nsISupports **aRetainedPeer) if (!aRetainedPeer) return NS_ERROR_NULL_POINTER; - *aRetainedPeer = NULL; + *aRetainedPeer = nullptr; if (!pstream || !pstream->ndata) return NS_ERROR_NULL_POINTER; @@ -560,13 +560,15 @@ MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target, case eNPPStreamTypeInternal_Get: { if (NS_FAILED(pluginHost->GetURL(inst, relativeURL, target, listener, - NULL, NULL, false))) + nullptr, nullptr, false))) return NPERR_GENERIC_ERROR; break; } case eNPPStreamTypeInternal_Post: { - if (NS_FAILED(pluginHost->PostURL(inst, relativeURL, len, buf, file, target, listener, NULL, NULL, false, 0, NULL))) + if (NS_FAILED(pluginHost->PostURL(inst, relativeURL, len, buf, file, + target, listener, nullptr, nullptr, + false, 0, nullptr))) return NPERR_GENERIC_ERROR; break; } @@ -687,7 +689,7 @@ doGetIdentifier(JSContext *cx, const NPUTF8* name) utf16name.Length()); if (!str) - return NULL; + return nullptr; return StringToNPIdentifier(cx, str); } @@ -698,7 +700,7 @@ InHeap(HANDLE hHeap, LPVOID lpMem) { BOOL success = FALSE; PROCESS_HEAP_ENTRY he; - he.lpData = NULL; + he.lpData = nullptr; while (HeapWalk(hHeap, &he) != 0) { if (he.lpData == lpMem) { success = TRUE; @@ -1261,7 +1263,7 @@ _getstringidentifier(const NPUTF8* name) { if (!name) { NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifier: passed null name")); - return NULL; + return nullptr; } if (!NS_IsMainThread()) { NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n")); @@ -1286,7 +1288,7 @@ _getstringidentifiers(const NPUTF8** names, int32_t nameCount, identifiers[i] = doGetIdentifier(cx, names[i]); } else { NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifiers: passed null name")); - identifiers[i] = NULL; + identifiers[i] = nullptr; } } } @@ -1307,7 +1309,7 @@ _utf8fromidentifier(NPIdentifier id) NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_utf8fromidentifier called from the wrong thread\n")); } if (!id) - return NULL; + return nullptr; if (!NPIdentifierIsString(id)) { return nullptr; @@ -2501,7 +2503,7 @@ void* NP_CALLBACK /* OJI type: JRIEnv* */ _getJavaEnv() { NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaEnv\n")); - return NULL; + return nullptr; } const char * NP_CALLBACK @@ -2542,7 +2544,7 @@ void* NP_CALLBACK /* OJI type: jref */ _getJavaPeer(NPP npp) { NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaPeer: npp=%p\n", (void*)npp)); - return NULL; + return nullptr; } void NP_CALLBACK @@ -2552,7 +2554,7 @@ _pushpopupsenabledstate(NPP npp, NPBool enabled) NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_pushpopupsenabledstate called from the wrong thread\n")); return; } - nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : NULL; + nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : nullptr; if (!inst) return; @@ -2566,7 +2568,7 @@ _poppopupsenabledstate(NPP npp) NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_poppopupsenabledstate called from the wrong thread\n")); return; } - nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : NULL; + nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : nullptr; if (!inst) return; diff --git a/dom/plugins/base/nsNPAPIPlugin.h b/dom/plugins/base/nsNPAPIPlugin.h index a806dbf6d221..636e460f0aa1 100644 --- a/dom/plugins/base/nsNPAPIPlugin.h +++ b/dom/plugins/base/nsNPAPIPlugin.h @@ -46,7 +46,7 @@ public: NS_DECL_ISUPPORTS - // Constructs and initializes an nsNPAPIPlugin object. A NULL file path + // Constructs and initializes an nsNPAPIPlugin object. A nullptr file path // will prevent this from calling NP_Initialize. static nsresult CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult); diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 604fee48c3bf..eff1eaa82163 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -193,7 +193,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance() #endif , mHaveJavaC2PJSObjectQuirk(false) { - mNPP.pdata = NULL; + mNPP.pdata = nullptr; mNPP.ndata = this; PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this)); @@ -536,7 +536,9 @@ nsNPAPIPluginInstance::Start() // before returning. If the plugin returns failure, we'll clear it out below. mRunning = RUNNING; - nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (uint16_t)mode, count, (char**)names, (char**)values, NULL, &error); + nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (uint16_t)mode, + count, (char**)names, (char**)values, + nullptr, &error); mInPluginInitCall = oldVal; NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL, @@ -554,7 +556,7 @@ nsNPAPIPluginInstance::Start() nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window) { - // NPAPI plugins don't want a SetWindow(NULL). + // NPAPI plugins don't want a SetWindow(nullptr). if (!window || RUNNING != mRunning) return NS_OK; @@ -1439,7 +1441,7 @@ PluginTimerCallback(nsITimer *aTimer, void *aClosure) // Make sure we still have an instance and the timer is still alive // after the callback. nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata; - if (!inst || !inst->TimerWithID(id, NULL)) + if (!inst || !inst->TimerWithID(id, nullptr)) return; // use UnscheduleTimer to clean up if this is a one-shot timer @@ -1476,7 +1478,7 @@ nsNPAPIPluginInstance::ScheduleTimer(uint32_t interval, NPBool repeat, void (*ti // generate ID that is unique to this instance uint32_t uniqueID = mTimers.Length(); - while ((uniqueID == 0) || TimerWithID(uniqueID, NULL)) + while ((uniqueID == 0) || TimerWithID(uniqueID, nullptr)) uniqueID++; newTimer->id = uniqueID; @@ -1599,7 +1601,7 @@ nsNPAPIPluginInstance::GetJSContext(JSContext* *outContext) nsRefPtr deathGrip(mOwner); - *outContext = NULL; + *outContext = nullptr; nsCOMPtr document; nsresult rv = mOwner->GetDocument(getter_AddRefs(document)); diff --git a/dom/plugins/base/nsPluginDirServiceProvider.cpp b/dom/plugins/base/nsPluginDirServiceProvider.cpp index 3a9c00f715e7..a5834e0e0e36 100644 --- a/dom/plugins/base/nsPluginDirServiceProvider.cpp +++ b/dom/plugins/base/nsPluginDirServiceProvider.cpp @@ -93,11 +93,11 @@ CopyVersion(verBlock *ver1, verBlock *ver2) static void TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion) { - WCHAR* szNum1 = NULL; - WCHAR* szNum2 = NULL; - WCHAR* szNum3 = NULL; - WCHAR* szNum4 = NULL; - WCHAR* szJavaBuild = NULL; + WCHAR* szNum1 = nullptr; + WCHAR* szNum2 = nullptr; + WCHAR* szNum3 = nullptr; + WCHAR* szNum4 = nullptr; + WCHAR* szJavaBuild = nullptr; WCHAR *strVer = nullptr; if (szVersion) { @@ -116,10 +116,10 @@ TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion) szJavaBuild[0] = '.'; } - szNum1 = wcstok(strVer, L"."); - szNum2 = wcstok(NULL, L"."); - szNum3 = wcstok(NULL, L"."); - szNum4 = wcstok(NULL, L"."); + szNum1 = wcstok(strVer, L"."); + szNum2 = wcstok(nullptr, L"."); + szNum3 = wcstok(nullptr, L"."); + szNum4 = wcstok(nullptr, L"."); vbVersion->wMajor = szNum1 ? (WORD) _wtoi(szNum1) : 0; vbVersion->wMinor = szNum2 ? (WORD) _wtoi(szNum2) : 0; diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index 0a79aef5a892..5c3eb9e2968a 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -1267,7 +1267,7 @@ static nsresult CreateNPAPIPlugin(nsPluginTag *aPluginTag, nsCOMPtr file = do_CreateInstance("@mozilla.org/file/local;1"); file->InitWithPath(NS_ConvertUTF8toUTF16(aPluginTag->mFullPath)); nsPluginFile pluginFile(file); - PRLibrary* pluginLibrary = NULL; + PRLibrary* pluginLibrary = nullptr; if (NS_FAILED(pluginFile.LoadPlugin(&pluginLibrary)) || !pluginLibrary) return NS_ERROR_FAILURE; @@ -1297,7 +1297,7 @@ nsresult nsPluginHost::EnsurePluginLoaded(nsPluginTag* aPluginTag) nsresult nsPluginHost::GetPlugin(const char *aMimeType, nsNPAPIPlugin** aPlugin) { nsresult rv = NS_ERROR_FAILURE; - *aPlugin = NULL; + *aPlugin = nullptr; if (!aMimeType) return NS_ERROR_ILLEGAL_VALUE; @@ -1510,7 +1510,7 @@ nsPluginHost::ClearSiteData(nsIPluginTag* plugin, const nsACString& domain, // If 'domain' is the null string, clear everything. if (domain.IsVoid()) { - return library->NPP_ClearSiteData(NULL, flags, maxAge); + return library->NPP_ClearSiteData(nullptr, flags, maxAge); } // Get the list of sites from the plugin. @@ -2108,8 +2108,8 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange invalidPlugins = invalidPlugin->mNext; - invalidPlugin->mPrev = NULL; - invalidPlugin->mNext = NULL; + invalidPlugin->mPrev = nullptr; + invalidPlugin->mNext = nullptr; } else { invalidPlugins->mSeen = false; @@ -2534,7 +2534,7 @@ nsPluginHost::ReadPluginInfo() file->GetNativeLeafName(derivedFileName); filename = derivedFileName.get(); } else { - filename = NULL; + filename = nullptr; } // skip the next line, useless in this version diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h index ef173c064127..01af0aa6d9fe 100644 --- a/dom/plugins/base/nsPluginHost.h +++ b/dom/plugins/base/nsPluginHost.h @@ -134,13 +134,13 @@ public: nsresult GetURLWithHeaders(nsNPAPIPluginInstance *pluginInst, const char* url, - const char* target = NULL, - nsNPAPIPluginStreamListener* streamListener = NULL, - const char* altHost = NULL, - const char* referrer = NULL, + const char* target = nullptr, + nsNPAPIPluginStreamListener* streamListener = nullptr, + const char* altHost = nullptr, + const char* referrer = nullptr, bool forceJSEnabled = false, uint32_t getHeadersLength = 0, - const char* getHeaders = NULL); + const char* getHeaders = nullptr); nsresult DoURLLoadSecurityCheck(nsNPAPIPluginInstance *aInstance, @@ -189,7 +189,7 @@ public: nsObjectLoadingContent *aContent, nsPluginInstanceOwner** aOwner); - // Does not accept NULL and should never fail. + // Does not accept nullptr and should never fail. nsPluginTag* TagForPlugin(nsNPAPIPlugin* aPlugin); nsresult GetPlugin(const char *aMimeType, nsNPAPIPlugin** aPlugin); diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index d762ae4ba892..ca89f9d52142 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -166,7 +166,7 @@ nsPluginInstanceOwner::GetImageContainer() // Right now we only draw with Gecko layers on Honeycomb and higher. See Paint() // for what we do on other versions. if (AndroidBridge::Bridge()->GetAPIVersion() < 11) - return NULL; + return nullptr; container = LayerManager::CreateImageContainer(); @@ -1354,8 +1354,8 @@ NPEventModel nsPluginInstanceOwner::GetEventModel() #define DEFAULT_REFRESH_RATE 20 // 50 FPS -nsCOMPtr *nsPluginInstanceOwner::sCATimer = NULL; -nsTArray *nsPluginInstanceOwner::sCARefreshListeners = NULL; +nsCOMPtr *nsPluginInstanceOwner::sCATimer = nullptr; +nsTArray *nsPluginInstanceOwner::sCARefreshListeners = nullptr; void nsPluginInstanceOwner::CARefresh(nsITimer *aTimer, void *aClosure) { if (!sCARefreshListeners) { @@ -1412,7 +1412,7 @@ void nsPluginInstanceOwner::AddToCARefreshTimer() { if (sCARefreshListeners->Length() == 1) { *sCATimer = do_CreateInstance("@mozilla.org/timer;1"); - (*sCATimer)->InitWithFuncCallback(CARefresh, NULL, + (*sCATimer)->InitWithFuncCallback(CARefresh, nullptr, DEFAULT_REFRESH_RATE, nsITimer::TYPE_REPEATING_SLACK); } } @@ -1428,10 +1428,10 @@ void nsPluginInstanceOwner::RemoveFromCARefreshTimer() { if (sCATimer) { (*sCATimer)->Cancel(); delete sCATimer; - sCATimer = NULL; + sCATimer = nullptr; } delete sCARefreshListeners; - sCARefreshListeners = NULL; + sCARefreshListeners = nullptr; } } @@ -1477,7 +1477,7 @@ void nsPluginInstanceOwner::RenderCoreAnimation(CGContextRef aCGContext, } if (mCARenderer->isInit() == false) { - void *caLayer = NULL; + void *caLayer = nullptr; nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginCoreAnimationLayer, &caLayer); if (NS_FAILED(rv) || !caLayer) { return; @@ -1494,12 +1494,12 @@ void nsPluginInstanceOwner::RenderCoreAnimation(CGContextRef aCGContext, FixUpPluginWindow(ePluginPaintEnable); } - CGImageRef caImage = NULL; + CGImageRef caImage = nullptr; nsresult rt = mCARenderer->Render(aWidth, aHeight, scaleFactor, &caImage); if (rt == NS_OK && mIOSurface && mColorProfile) { nsCARenderer::DrawSurfaceToCGContext(aCGContext, mIOSurface, mColorProfile, 0, 0, aWidth, aHeight); - } else if (rt == NS_OK && caImage != NULL) { + } else if (rt == NS_OK && caImage != nullptr) { // Significant speed up by resetting the scaling ::CGContextSetInterpolationQuality(aCGContext, kCGInterpolationNone ); ::CGContextTranslateCTM(aCGContext, 0, (double) aHeight * scaleFactor); @@ -2989,7 +2989,7 @@ void* nsPluginInstanceOwner::GetPluginPortFromWidget() { //!!! Port must be released for windowless plugins on Windows, because it is HDC !!! - void* result = NULL; + void* result = nullptr; if (mWidget) { #ifdef XP_WIN if (mPluginWindow && (mPluginWindow->type == NPWindowTypeDrawable)) @@ -3081,7 +3081,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) } if (mObjectFrame) { - // NULL widget is fine, will result in windowless setup. + // nullptr widget is fine, will result in windowless setup. mObjectFrame->PrepForDrawing(mWidget); } diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index f327a10f8d2f..55e2fae457ac 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -165,7 +165,7 @@ public: const char* GetPluginName() { if (mInstance && mPluginHost) { - const char* name = NULL; + const char* name = nullptr; if (NS_SUCCEEDED(mPluginHost->GetPluginName(mInstance, &name)) && name) return name; } diff --git a/dom/plugins/base/nsPluginModule.cpp b/dom/plugins/base/nsPluginModule.cpp index ecd3ece85f0e..539db8852c79 100644 --- a/dom/plugins/base/nsPluginModule.cpp +++ b/dom/plugins/base/nsPluginModule.cpp @@ -11,13 +11,13 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPluginHost, nsPluginHost::GetInst) NS_DEFINE_NAMED_CID(NS_PLUGIN_HOST_CID); static const mozilla::Module::CIDEntry kPluginCIDs[] = { - { &kNS_PLUGIN_HOST_CID, false, NULL, nsPluginHostConstructor }, - { NULL } + { &kNS_PLUGIN_HOST_CID, false, nullptr, nsPluginHostConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kPluginContracts[] = { { MOZ_PLUGIN_HOST_CONTRACTID, &kNS_PLUGIN_HOST_CID }, - { NULL } + { nullptr } }; static const mozilla::Module kPluginModule = { diff --git a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp index 38e13eecf5e5..f79e5ed4f16a 100644 --- a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp +++ b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp @@ -175,15 +175,15 @@ nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow(bool aEnableXtFocus) { // removed, which means we're destroying it more than once. // SYNTAX ERROR. g_signal_connect(mSocketWidget, "plug_removed", - G_CALLBACK(plug_removed_cb), NULL); + G_CALLBACK(plug_removed_cb), nullptr); g_signal_connect(mSocketWidget, "unrealize", - G_CALLBACK(socket_unrealize_cb), NULL); + G_CALLBACK(socket_unrealize_cb), nullptr); g_signal_connect(mSocketWidget, "destroy", G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); - gpointer user_data = NULL; + gpointer user_data = nullptr; gdk_window_get_user_data(parent_win, &user_data); GtkContainer *container = GTK_CONTAINER(user_data); @@ -197,7 +197,7 @@ nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow(bool aEnableXtFocus) { // painting this window, avoiding flicker. // TODO GTK3 #if (MOZ_WIDGET_GTK == 2) - gdk_window_set_back_pixmap(gtk_widget_get_window(mSocketWidget), NULL, FALSE); + gdk_window_set_back_pixmap(gtk_widget_get_window(mSocketWidget), nullptr, FALSE); #endif // Resize before we show @@ -262,11 +262,11 @@ nsresult nsPluginNativeWindowGtk2::CreateXtWindow() { gtk_widget_set_size_request(mSocketWidget, width, height); #ifdef DEBUG - printf("About to show xtbin(%p)...\n", (void*)mSocketWidget); fflush(NULL); + printf("About to show xtbin(%p)...\n", (void*)mSocketWidget); fflush(nullptr); #endif gtk_widget_show(mSocketWidget); #ifdef DEBUG - printf("completed gtk_widget_show(%p)\n", (void*)mSocketWidget); fflush(NULL); + printf("completed gtk_widget_show(%p)\n", (void*)mSocketWidget); fflush(nullptr); #endif // Fill out the ws_info structure. diff --git a/dom/plugins/base/nsPluginNativeWindowOS2.cpp b/dom/plugins/base/nsPluginNativeWindowOS2.cpp index 62a13b9ded81..3721e391e739 100644 --- a/dom/plugins/base/nsPluginNativeWindowOS2.cpp +++ b/dom/plugins/base/nsPluginNativeWindowOS2.cpp @@ -59,7 +59,7 @@ public: ULONG GetMsg() { return mMsg; }; MPARAM GetWParam() { return mWParam; }; MPARAM GetLParam() { return mLParam; }; - bool InUse() { return (mWnd!=NULL); }; + bool InUse() { return mWnd != nullptr; }; NS_DECL_NSIRUNNABLE @@ -78,7 +78,7 @@ PluginWindowEvent::PluginWindowEvent() void PluginWindowEvent::Clear() { - mWnd = NULL; + mWnd = nullptr; mMsg = 0; mWParam = 0; mLParam = 0; @@ -87,8 +87,8 @@ void PluginWindowEvent::Clear() void PluginWindowEvent::Init(const PluginWindowWeakRef &ref, HWND aWnd, ULONG aMsg, MPARAM mp1, MPARAM mp2) { - NS_ASSERTION(aWnd != NULL, "invalid plugin event value"); - NS_ASSERTION(mWnd == NULL, "event already in use"); + NS_ASSERTION(aWnd != nullptr, "invalid plugin event value"); + NS_ASSERTION(mWnd == nullptr, "event already in use"); mPluginWindowRef = ref; mWnd = aWnd; mMsg = aMsg; @@ -351,7 +351,7 @@ nsPluginNativeWindowOS2::nsPluginNativeWindowOS2() : nsPluginNativeWindow() width = 0; height = 0; - mPluginWinProc = NULL; + mPluginWinProc = nullptr; mPluginType = nsPluginType_Unknown; // once the atom has been added, it won't be deleted diff --git a/dom/plugins/base/nsPluginNativeWindowWin.cpp b/dom/plugins/base/nsPluginNativeWindowWin.cpp index 490aa264121c..927abcb18d61 100644 --- a/dom/plugins/base/nsPluginNativeWindowWin.cpp +++ b/dom/plugins/base/nsPluginNativeWindowWin.cpp @@ -56,7 +56,7 @@ public: UINT GetMsg() { return mMsg; }; WPARAM GetWParam() { return mWParam; }; LPARAM GetLParam() { return mLParam; }; - bool InUse() { return (mWnd!=NULL); }; + bool InUse() { return mWnd != nullptr; }; NS_DECL_NSIRUNNABLE @@ -75,7 +75,7 @@ PluginWindowEvent::PluginWindowEvent() void PluginWindowEvent::Clear() { - mWnd = NULL; + mWnd = nullptr; mMsg = 0; mWParam = 0; mLParam = 0; @@ -84,8 +84,8 @@ void PluginWindowEvent::Clear() void PluginWindowEvent::Init(const PluginWindowWeakRef &ref, HWND aWnd, UINT aMsg, WPARAM aWParam, LPARAM aLParam) { - NS_ASSERTION(aWnd != NULL, "invalid plugin event value"); - NS_ASSERTION(mWnd == NULL, "event already in use"); + NS_ASSERTION(aWnd != nullptr, "invalid plugin event value"); + NS_ASSERTION(mWnd == nullptr, "event already in use"); mPluginWindowRef = ref; mWnd = aWnd; mMsg = aMsg; @@ -375,8 +375,8 @@ typedef LONG_PTR (WINAPI *User32SetWindowLongPtrW)(HWND hWnd, int nIndex, LONG_PTR dwNewLong); -static User32SetWindowLongPtrA sUser32SetWindowLongAHookStub = NULL; -static User32SetWindowLongPtrW sUser32SetWindowLongWHookStub = NULL; +static User32SetWindowLongPtrA sUser32SetWindowLongAHookStub = nullptr; +static User32SetWindowLongPtrW sUser32SetWindowLongWHookStub = nullptr; #else typedef LONG (WINAPI *User32SetWindowLongA)(HWND hWnd, @@ -386,8 +386,8 @@ typedef LONG (WINAPI *User32SetWindowLongW)(HWND hWnd, int nIndex, LONG dwNewLong); -static User32SetWindowLongA sUser32SetWindowLongAHookStub = NULL; -static User32SetWindowLongW sUser32SetWindowLongWHookStub = NULL; +static User32SetWindowLongA sUser32SetWindowLongAHookStub = nullptr; +static User32SetWindowLongW sUser32SetWindowLongWHookStub = nullptr; #endif static inline bool SetWindowLongHookCheck(HWND hWnd, @@ -498,11 +498,11 @@ nsPluginNativeWindowWin::nsPluginNativeWindowWin() : nsPluginNativeWindow() width = 0; height = 0; - mPrevWinProc = NULL; - mPluginWinProc = NULL; + mPrevWinProc = nullptr; + mPluginWinProc = nullptr; mPluginType = nsPluginType_Unknown; - mParentWnd = NULL; + mParentWnd = nullptr; mParentProc = 0; if (!sWM_FLASHBOUNCEMSG) { @@ -720,7 +720,7 @@ nsresult nsPluginNativeWindowWin::UndoSubclassAndAssociateWindow() WNDPROC currentWndProc = (WNDPROC)::GetWindowLongPtr(hWnd, GWLP_WNDPROC); if (currentWndProc == PluginWndProc) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)mPluginWinProc); - mPluginWinProc = NULL; + mPluginWinProc = nullptr; LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE); style &= ~WS_CLIPCHILDREN; @@ -729,7 +729,7 @@ nsresult nsPluginNativeWindowWin::UndoSubclassAndAssociateWindow() if (mPluginType == nsPluginType_PDF && mParentWnd) { ::SetWindowLongPtr(mParentWnd, GWLP_WNDPROC, mParentProc); - mParentWnd = NULL; + mParentWnd = nullptr; mParentProc = 0; } diff --git a/dom/plugins/base/nsPluginsDirDarwin.cpp b/dom/plugins/base/nsPluginsDirDarwin.cpp index fe0bca79a587..f33e233ccd60 100644 --- a/dom/plugins/base/nsPluginsDirDarwin.cpp +++ b/dom/plugins/base/nsPluginsDirDarwin.cpp @@ -44,12 +44,15 @@ typedef NS_NPAPIPLUGIN_CALLBACK(OSErr, BP_GETSUPPORTEDMIMETYPES) (BPSupportedMIM */ static CFBundleRef getPluginBundle(const char* path) { - CFBundleRef bundle = NULL; - CFStringRef pathRef = ::CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8); + CFBundleRef bundle = nullptr; + CFStringRef pathRef = ::CFStringCreateWithCString(nullptr, path, + kCFStringEncodingUTF8); if (pathRef) { - CFURLRef bundleURL = ::CFURLCreateWithFileSystemPath(NULL, pathRef, kCFURLPOSIXPathStyle, true); + CFURLRef bundleURL = ::CFURLCreateWithFileSystemPath(nullptr, pathRef, + kCFURLPOSIXPathStyle, + true); if (bundleURL) { - bundle = ::CFBundleCreate(NULL, bundleURL); + bundle = ::CFBundleCreate(nullptr, bundleURL); ::CFRelease(bundleURL); } ::CFRelease(pathRef); @@ -144,57 +147,57 @@ static CFDictionaryRef ParsePlistForMIMETypesFilename(CFBundleRef bundle) { CFTypeRef mimeFileName = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypesFilename")); if (!mimeFileName || ::CFGetTypeID(mimeFileName) != ::CFStringGetTypeID()) { - return NULL; + return nullptr; } FSRef homeDir; if (::FSFindFolder(kUserDomain, kCurrentUserFolderType, kDontCreateFolder, &homeDir) != noErr) { - return NULL; + return nullptr; } CFURLRef userDirURL = ::CFURLCreateFromFSRef(kCFAllocatorDefault, &homeDir); if (!userDirURL) { - return NULL; + return nullptr; } AutoCFTypeObject userDirURLAutorelease(userDirURL); - CFStringRef mimeFilePath = ::CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("Library/Preferences/%@"), static_cast(mimeFileName)); + CFStringRef mimeFilePath = ::CFStringCreateWithFormat(kCFAllocatorDefault, nullptr, CFSTR("Library/Preferences/%@"), static_cast(mimeFileName)); if (!mimeFilePath) { - return NULL; + return nullptr; } AutoCFTypeObject mimeFilePathAutorelease(mimeFilePath); CFURLRef mimeFileURL = ::CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorDefault, mimeFilePath, kCFURLPOSIXPathStyle, false, userDirURL); if (!mimeFileURL) { - return NULL; + return nullptr; } AutoCFTypeObject mimeFileURLAutorelease(mimeFileURL); SInt32 errorCode = 0; - CFDataRef mimeFileData = NULL; - Boolean result = ::CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, mimeFileURL, &mimeFileData, NULL, NULL, &errorCode); + CFDataRef mimeFileData = nullptr; + Boolean result = ::CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, mimeFileURL, &mimeFileData, nullptr, nullptr, &errorCode); if (!result) { - return NULL; + return nullptr; } AutoCFTypeObject mimeFileDataAutorelease(mimeFileData); if (errorCode != 0) { - return NULL; + return nullptr; } - CFPropertyListRef propertyList = ::CFPropertyListCreateFromXMLData(kCFAllocatorDefault, mimeFileData, kCFPropertyListImmutable, NULL); + CFPropertyListRef propertyList = ::CFPropertyListCreateFromXMLData(kCFAllocatorDefault, mimeFileData, kCFPropertyListImmutable, nullptr); if (!propertyList) { - return NULL; + return nullptr; } AutoCFTypeObject propertyListAutorelease(propertyList); if (::CFGetTypeID(propertyList) != ::CFDictionaryGetTypeID()) { - return NULL; + return nullptr; } CFTypeRef mimeTypes = ::CFDictionaryGetValue(static_cast(propertyList), CFSTR("WebPluginMIMETypes")); if (!mimeTypes || ::CFGetTypeID(mimeTypes) != ::CFDictionaryGetTypeID() || ::CFDictionaryGetCount(static_cast(mimeTypes)) == 0) { - return NULL; + return nullptr; } return static_cast(::CFRetain(mimeTypes)); @@ -301,11 +304,14 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary) executablePath[0] = '\0'; nsAutoCString bundlePath; mPlugin->GetNativePath(bundlePath); - CFStringRef pathRef = ::CFStringCreateWithCString(NULL, bundlePath.get(), kCFStringEncodingUTF8); + CFStringRef pathRef = ::CFStringCreateWithCString(nullptr, bundlePath.get(), + kCFStringEncodingUTF8); if (pathRef) { - CFURLRef bundleURL = ::CFURLCreateWithFileSystemPath(NULL, pathRef, kCFURLPOSIXPathStyle, true); + CFURLRef bundleURL = ::CFURLCreateWithFileSystemPath(nullptr, pathRef, + kCFURLPOSIXPathStyle, + true); if (bundleURL) { - CFBundleRef bundle = ::CFBundleCreate(NULL, bundleURL); + CFBundleRef bundle = ::CFBundleCreate(nullptr, bundleURL); if (bundle) { CFURLRef executableURL = ::CFBundleCopyExecutableURL(bundle); if (executableURL) { @@ -356,7 +362,7 @@ static char* GetNextPluginStringFromHandle(Handle h, short *index) static bool IsCompatibleArch(nsIFile *file) { - CFURLRef pluginURL = NULL; + CFURLRef pluginURL = nullptr; if (NS_FAILED(toCFURLRef(file, pluginURL))) return false; @@ -483,7 +489,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary) } // We'll fill this in using BP_GetSupportedMIMETypes and/or resource fork data - BPSupportedMIMETypes mi = {kBPSupportedMIMETypesStructVers_1, NULL, NULL}; + BPSupportedMIMETypes mi = {kBPSupportedMIMETypesStructVers_1, nullptr, nullptr}; // Try to get data from BP_GetSupportedMIMETypes if (pLibrary) { diff --git a/dom/plugins/base/nsPluginsDirOS2.cpp b/dom/plugins/base/nsPluginsDirOS2.cpp index 523b1c62808f..43a1b3b242cc 100644 --- a/dom/plugins/base/nsPluginsDirOS2.cpp +++ b/dom/plugins/base/nsPluginsDirOS2.cpp @@ -63,7 +63,7 @@ static char *LoadRCDATAVersion(HMODULE hMod, ULONG resid) // version info is should be 8 chars if (rc == NO_ERROR && ulSize == 8) { - char *version = NULL; + char *version = nullptr; rc = DosGetResource(hMod, RT_RCDATA, resid, (void**) &version); if (rc == NO_ERROR) diff --git a/dom/plugins/base/nsPluginsDirUnix.cpp b/dom/plugins/base/nsPluginsDirUnix.cpp index 42601da9b094..c13f2be9afdf 100644 --- a/dom/plugins/base/nsPluginsDirUnix.cpp +++ b/dom/plugins/base/nsPluginsDirUnix.cpp @@ -93,7 +93,7 @@ static bool LoadExtraSharedLib(const char *name, char **soname, bool tryToGetSon if (tryToGetSoname) { SearchForSoname(name, soname); if (*soname) { - ret = LoadExtraSharedLib((const char *) *soname, NULL, false); + ret = LoadExtraSharedLib((const char *) *soname, nullptr, false); } } } @@ -120,7 +120,7 @@ static void LoadExtraSharedLibs() nsresult res; nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &res)); if (NS_SUCCEEDED(res) && (prefs != nullptr)) { - char *sonameList = NULL; + char *sonameList = nullptr; bool prefSonameListIsSet = true; res = prefs->GetCharPref(PREF_PLUGINS_SONAME, &sonameList); if (!sonameList) { @@ -171,7 +171,7 @@ static void LoadExtraSharedLibs() } else tryToGetSoname = false; } - char *soname = NULL; + char *soname = nullptr; if (LoadExtraSharedLib(arrayOfLibs[i], &soname, tryToGetSoname)) { //construct soname's list to save in prefs p = soname ? soname : arrayOfLibs[i]; @@ -220,7 +220,7 @@ bool nsPluginsDir::IsPluginFile(nsIFile* file) // 'libstagefright_froyo.so' on honeycomb, we will abort. // Since these are just helper libs, we can ignore. const char *cFile = filename.get(); - if (strstr(cFile, "libstagefright") != NULL) + if (strstr(cFile, "libstagefright") != nullptr) return false; #endif @@ -364,8 +364,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary) return NS_ERROR_FAILURE; } - const char *name = NULL; - npGetValue(NULL, NPPVpluginNameString, &name); + const char *name = nullptr; + npGetValue(nullptr, NPPVpluginNameString, &name); if (name) { info.fName = PL_strdup(name); } @@ -373,8 +373,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary) info.fName = PL_strdup(fileName.get()); } - const char *description = NULL; - npGetValue(NULL, NPPVpluginDescriptionString, &description); + const char *description = nullptr; + npGetValue(nullptr, NPPVpluginDescriptionString, &description); if (description) { info.fDescription = PL_strdup(description); } diff --git a/dom/plugins/base/nsPluginsDirWin.cpp b/dom/plugins/base/nsPluginsDirWin.cpp index 114ef7e05e88..96b7f0c37b17 100644 --- a/dom/plugins/base/nsPluginsDirWin.cpp +++ b/dom/plugins/base/nsPluginsDirWin.cpp @@ -72,7 +72,7 @@ static char* GetKeyValue(void* verbuf, const WCHAR* key, WCHAR keybuf[64]; // plenty for the template below, with the longest key // we use (currently "FileDescription") const WCHAR keyFormat[] = L"\\StringFileInfo\\%04X%04X\\%s"; - WCHAR *buf = NULL; + WCHAR *buf = nullptr; UINT blen; if (_snwprintf_s(keybuf, ArrayLength(keybuf), _TRUNCATE, @@ -135,11 +135,11 @@ static char** MakeStringArray(uint32_t variants, char* data) // We should handle such situations gracefully if ((variants <= 0) || !data) - return NULL; + return nullptr; char ** array = (char **)PR_Calloc(variants, sizeof(char *)); if (!array) - return NULL; + return nullptr; char * start = data; @@ -172,7 +172,7 @@ static void FreeStringArray(uint32_t variants, char ** array) for (uint32_t i = 0; i < variants; i++) { if (array[i]) { PL_strfree(array[i]); - array[i] = NULL; + array[i] = nullptr; } } PR_Free(array); @@ -184,14 +184,14 @@ static bool CanLoadPlugin(const PRUnichar* aBinaryPath) bool canLoad = false; HANDLE file = CreateFileW(aBinaryPath, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (file != INVALID_HANDLE_VALUE) { - HANDLE map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, - GetFileSize(file, NULL), NULL); - if (map != NULL) { + HANDLE map = CreateFileMappingW(file, nullptr, PAGE_READONLY, 0, + GetFileSize(file, nullptr), nullptr); + if (map != nullptr) { LPVOID mapView = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0); - if (mapView != NULL) { + if (mapView != nullptr) { if (((IMAGE_DOS_HEADER*)mapView)->e_magic == IMAGE_DOS_SIGNATURE) { long peImageHeaderStart = (((IMAGE_DOS_HEADER*)mapView)->e_lfanew); if (peImageHeaderStart != 0L) { @@ -300,12 +300,12 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary) } if (protectCurrentDirectory) { - SetDllDirectory(NULL); + SetDllDirectory(nullptr); } nsresult rv = mPlugin->Load(outLibrary); if (NS_FAILED(rv)) - *outLibrary = NULL; + *outLibrary = nullptr; if (protectCurrentDirectory) { SetDllDirectory(L"");