diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 768cd4c00b76..9431d4c68a5f 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -71,7 +71,6 @@ #include "nsArrayEnumerator.h" #include "nsStringEnumerator.h" #include "mozilla/FileUtils.h" -#include "mozilla/UniquePtr.h" #include "nsDataHashtable.h" #include // for placement new @@ -621,18 +620,18 @@ DoRegisterManifest(NSLocationType aType, MOZ_ASSERT(!aXPTOnly || !nsComponentManagerImpl::gComponentManager); uint32_t len; FileLocation::Data data; - UniquePtr buf; + nsAutoArrayPtr buf; nsresult rv = aFile.GetData(data); if (NS_SUCCEEDED(rv)) { rv = data.GetSize(&len); } if (NS_SUCCEEDED(rv)) { - buf = MakeUnique(len + 1); - rv = data.Copy(buf.get(), len); + buf = new char[len + 1]; + rv = data.Copy(buf, len); } if (NS_SUCCEEDED(rv)) { buf[len] = '\0'; - ParseManifest(aType, aFile, buf.get(), aChromeOnly, aXPTOnly); + ParseManifest(aType, aFile, buf, aChromeOnly, aXPTOnly); } else if (NS_BOOTSTRAPPED_LOCATION != aType) { nsCString uri; aFile.GetURIString(uri); @@ -700,17 +699,17 @@ DoRegisterXPT(FileLocation& aFile) uint32_t len; FileLocation::Data data; - UniquePtr buf; + nsAutoArrayPtr buf; nsresult rv = aFile.GetData(data); if (NS_SUCCEEDED(rv)) { rv = data.GetSize(&len); } if (NS_SUCCEEDED(rv)) { - buf = MakeUnique(len); - rv = data.Copy(buf.get(), len); + buf = new char[len]; + rv = data.Copy(buf, len); } if (NS_SUCCEEDED(rv)) { - XPTInterfaceInfoManager::GetSingleton()->RegisterBuffer(buf.get(), len); + XPTInterfaceInfoManager::GetSingleton()->RegisterBuffer(buf, len); #ifdef MOZ_B2G_LOADER MarkRegisteredXPTIInfo(aFile); #endif diff --git a/xpcom/glue/nsINIParser.cpp b/xpcom/glue/nsINIParser.cpp index 53eae7292900..71b028f60555 100644 --- a/xpcom/glue/nsINIParser.cpp +++ b/xpcom/glue/nsINIParser.cpp @@ -24,8 +24,6 @@ #define READ_BINARYMODE "r" #endif -using namespace mozilla; - #ifdef XP_WIN inline FILE* TS_tfopen(const char* aPath, const wchar_t* aMode) @@ -125,7 +123,7 @@ nsINIParser::InitFromFILE(FILE* aFd) } /* malloc an internal buf the size of the file */ - mFileContents = MakeUnique(flen + 2); + mFileContents = new char[flen + 2]; if (!mFileContents) { return NS_ERROR_OUT_OF_MEMORY; } @@ -135,7 +133,7 @@ nsINIParser::InitFromFILE(FILE* aFd) return NS_BASE_STREAM_OSERROR; } - int rd = fread(mFileContents.get(), sizeof(char), flen, aFd); + int rd = fread(mFileContents, sizeof(char), flen, aFd); if (rd != flen) { return NS_BASE_STREAM_OSERROR; } @@ -174,13 +172,13 @@ nsINIParser::InitFromFILE(FILE* aFd) return NS_ERROR_FAILURE; } - UniquePtr utf8Buffer(new char[flen]); + nsAutoArrayPtr utf8Buffer(new char[flen]); if (WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast(buffer), -1, - utf8Buffer.get(), flen, nullptr, nullptr) == 0) { + utf8Buffer, flen, nullptr, nullptr) == 0) { return NS_ERROR_FAILURE; } - mFileContents = Move(utf8Buffer); - buffer = mFileContents.get(); + mFileContents = utf8Buffer.forget(); + buffer = mFileContents; } #endif @@ -244,13 +242,13 @@ nsINIParser::InitFromFILE(FILE* aFd) break; } if (!v->next) { - v->next = MakeUnique(key, token); + v->next = new INIValue(key, token); if (!v->next) { return NS_ERROR_OUT_OF_MEMORY; } break; } - v = v->next.get(); + v = v->next; } NS_ASSERTION(v, "v should never be null coming out of this loop"); } @@ -271,7 +269,7 @@ nsINIParser::GetString(const char* aSection, const char* aKey, return NS_OK; } - val = val->next.get(); + val = val->next; } return NS_ERROR_FAILURE; @@ -295,7 +293,7 @@ nsINIParser::GetString(const char* aSection, const char* aKey, return NS_OK; } - val = val->next.get(); + val = val->next; } return NS_ERROR_FAILURE; @@ -320,7 +318,7 @@ nsINIParser::GetStrings(const char* aSection, for (mSections.Get(aSection, &val); val; - val = val->next.get()) { + val = val->next) { if (!aCB(val->key, val->value, aClosure)) { return NS_OK; diff --git a/xpcom/glue/nsINIParser.h b/xpcom/glue/nsINIParser.h index d0f553d49db1..65fbf8576cbf 100644 --- a/xpcom/glue/nsINIParser.h +++ b/xpcom/glue/nsINIParser.h @@ -15,7 +15,7 @@ #include "nscore.h" #include "nsClassHashtable.h" -#include "mozilla/UniquePtr.h" +#include "nsAutoPtr.h" #include @@ -106,11 +106,11 @@ private: const char* key; const char* value; - mozilla::UniquePtr next; + nsAutoPtr next; }; nsClassHashtable mSections; - mozilla::UniquePtr mFileContents; + nsAutoArrayPtr mFileContents; nsresult InitFromFILE(FILE* aFd); }; diff --git a/xpcom/tests/gtest/TestExpirationTracker.cpp b/xpcom/tests/gtest/TestExpirationTracker.cpp index a6a0e146cfbe..67385d1cf226 100644 --- a/xpcom/tests/gtest/TestExpirationTracker.cpp +++ b/xpcom/tests/gtest/TestExpirationTracker.cpp @@ -18,7 +18,6 @@ #include "nsIFile.h" #include "prinrval.h" #include "nsThreadUtils.h" -#include "mozilla/UniquePtr.h" #include "gtest/gtest.h" namespace TestExpirationTracker { @@ -50,7 +49,7 @@ public: LogAction(obj, "Created"); } - nsTArray> mUniverse; + nsTArray > mUniverse; void LogAction(Object* aObj, const char* aAction) { if (logging) { @@ -80,28 +79,28 @@ public: break; } case 1: { - UniquePtr& objref = mUniverse[uint32_t(rand())%mUniverse.Length()]; - if (objref->mExpiration.IsTracked()) { - nsExpirationTracker::RemoveObject(objref.get()); - LogAction(objref.get(), "Removed"); + obj = mUniverse[uint32_t(rand())%mUniverse.Length()]; + if (obj->mExpiration.IsTracked()) { + nsExpirationTracker::RemoveObject(obj); + LogAction(obj, "Removed"); } break; } case 2: { - UniquePtr& objref = mUniverse[uint32_t(rand())%mUniverse.Length()]; - if (!objref->mExpiration.IsTracked()) { - objref->Touch(); - nsExpirationTracker::AddObject(objref.get()); - LogAction(objref.get(), "Added"); + obj = mUniverse[uint32_t(rand())%mUniverse.Length()]; + if (!obj->mExpiration.IsTracked()) { + obj->Touch(); + nsExpirationTracker::AddObject(obj); + LogAction(obj, "Added"); } break; } case 3: { - UniquePtr& objref = mUniverse[uint32_t(rand())%mUniverse.Length()]; - if (objref->mExpiration.IsTracked()) { - objref->Touch(); - nsExpirationTracker::MarkUsed(objref.get()); - LogAction(objref.get(), "Marked used"); + obj = mUniverse[uint32_t(rand())%mUniverse.Length()]; + if (obj->mExpiration.IsTracked()) { + obj->Touch(); + nsExpirationTracker::MarkUsed(obj); + LogAction(obj, "Marked used"); } break; }