Bug 780387 - Part e: Stop using PRSize; r=bsmedberg
authorMs2ger <ms2ger@gmail.com>
Thu, 09 Aug 2012 09:10:11 +0200
changeset 101854 44fe712a01c88f3be3bf1d3ee8b1c74ff4062496
parent 101853 25378953c5843e7be9df9fb22e7dc6e9f90f87bd
child 101855 5b0ac8d41b804bc3e854bde85a1afd52f75ef070
push id23254
push userMs2ger@gmail.com
push dateThu, 09 Aug 2012 07:22:25 +0000
treeherdermozilla-central@3199bc043da4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs780387
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 780387 - Part e: Stop using PRSize; r=bsmedberg
image/src/RasterImage.cpp
layout/base/nsBidi.cpp
layout/base/nsBidi.h
netwerk/protocol/http/nsHttpAuthCache.cpp
netwerk/protocol/http/nsHttpAuthCache.h
rdf/base/src/nsRDFService.cpp
xpcom/base/nsMemoryImpl.cpp
xpcom/base/nsTraceRefcntImpl.cpp
xpcom/base/nsUUIDGenerator.cpp
xpcom/build/nsXPCOM.h
xpcom/build/nsXPCOMPrivate.h
xpcom/glue/DeadlockDetector.h
xpcom/glue/nsMemory.cpp
xpcom/glue/nsMemory.h
xpcom/glue/standalone/nsXPCOMGlue.cpp
xpcom/stub/nsXPComStub.cpp
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -1526,17 +1526,17 @@ RasterImage::AddSourceData(const char *a
            discardable_source_bytes));
 
   return NS_OK;
 }
 
 /* Note!  buf must be declared as char buf[9]; */
 // just used for logging and hashing the header
 static void
-get_header_str (char *buf, char *data, PRSize data_len)
+get_header_str (char *buf, char *data, size_t data_len)
 {
   int i;
   int n;
   static char hex[] = "0123456789abcdef";
 
   n = data_len < 4 ? data_len : 4;
 
   for (i = 0; i < n; i++) {
--- a/layout/base/nsBidi.cpp
+++ b/layout/base/nsBidi.cpp
@@ -179,17 +179,17 @@ void nsBidi::Init()
  *
  * Assume aSizeNeeded>0.
  * If *aMemory!=NULL, then assume *aSize>0.
  *
  * ### this realloc() may unnecessarily copy the old data,
  * which we know we don't need any more;
  * is this the best way to do this??
  */
-bool nsBidi::GetMemory(void **aMemory, PRSize *aSize, bool aMayAllocate, PRSize aSizeNeeded)
+bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t aSizeNeeded)
 {
   /* check for existing memory */
   if(*aMemory==NULL) {
     /* we need to allocate memory */
     if(!aMayAllocate) {
       return false;
     } else {
       *aMemory=PR_MALLOC(aSizeNeeded);
--- a/layout/base/nsBidi.h
+++ b/layout/base/nsBidi.h
@@ -818,17 +818,17 @@ public:
 
 protected:
   friend class nsBidiPresUtils;
 
   /** length of the current text */
   PRInt32 mLength;
 
   /** memory sizes in bytes */
-  PRSize mDirPropsSize, mLevelsSize, mRunsSize;
+  size_t mDirPropsSize, mLevelsSize, mRunsSize;
 
   /** allocated memory */
   DirProp* mDirPropsMemory;
   nsBidiLevel* mLevelsMemory;
   Run* mRunsMemory;
 
   /** indicators for whether memory may be allocated after construction */
   bool mMayAllocateText, mMayAllocateRuns;
@@ -855,17 +855,17 @@ protected:
 
   /** for non-mixed text, we only need a tiny array of runs (no malloc()) */
   Run mSimpleRuns[1];
 
 private:
 
   void Init();
 
-  bool GetMemory(void **aMemory, PRSize* aSize, bool aMayAllocate, PRSize aSizeNeeded);
+  bool GetMemory(void **aMemory, size_t* aSize, bool aMayAllocate, size_t aSizeNeeded);
 
   void Free();
 
   void GetDirProps(const PRUnichar *aText);
 
   nsBidiDirection ResolveExplicitLevels();
 
   nsresult CheckExplicitLevels(nsBidiDirection *aDirection);
--- a/netwerk/protocol/http/nsHttpAuthCache.cpp
+++ b/netwerk/protocol/http/nsHttpAuthCache.cpp
@@ -185,17 +185,17 @@ nsHttpAuthCache::LookupAuthNode(const ch
         return nullptr;
 
     GetAuthKey(scheme, host, port, key);
 
     return (nsHttpAuthNode *) PL_HashTableLookup(mDB, key.get());
 }
 
 void *
-nsHttpAuthCache::AllocTable(void *self, PRSize size)
+nsHttpAuthCache::AllocTable(void *self, size_t size)
 {
     return malloc(size);
 }
 
 void
 nsHttpAuthCache::FreeTable(void *self, void *item)
 {
     free(item);
--- a/netwerk/protocol/http/nsHttpAuthCache.h
+++ b/netwerk/protocol/http/nsHttpAuthCache.h
@@ -216,17 +216,17 @@ public:
 
 private:
     nsHttpAuthNode *LookupAuthNode(const char *scheme,
                                    const char *host,
                                    PRInt32     port,
                                    nsCString  &key);
 
     // hash table allocation functions
-    static void*        AllocTable(void *, PRSize size);
+    static void*        AllocTable(void *, size_t size);
     static void         FreeTable(void *, void *item);
     static PLHashEntry* AllocEntry(void *, const void *key);
     static void         FreeEntry(void *, PLHashEntry *he, PRUintn flag);
 
     static PLHashAllocOps gHashAllocOps;
     
 private:
     PLHashTable *mDB; // "host:port" --> nsHttpAuthNode
--- a/rdf/base/src/nsRDFService.cpp
+++ b/rdf/base/src/nsRDFService.cpp
@@ -77,17 +77,17 @@ static PRLogModuleInfo* gLog = nullptr;
 
 class BlobImpl;
 
 // These functions are copied from nsprpub/lib/ds/plhash.c, with one
 // change to free the key in DataSourceFreeEntry.
 // XXX sigh, why were DefaultAllocTable et. al. declared static, anyway?
 
 static void *
-DataSourceAllocTable(void *pool, PRSize size)
+DataSourceAllocTable(void *pool, size_t size)
 {
     return PR_MALLOC(size);
 }
 
 static void
 DataSourceFreeTable(void *pool, void *item)
 {
     PR_Free(item);
--- a/xpcom/base/nsMemoryImpl.cpp
+++ b/xpcom/base/nsMemoryImpl.cpp
@@ -21,23 +21,23 @@
 #include "nsString.h"
 #include "mozilla/Services.h"
 
 static nsMemoryImpl sGlobalMemory;
 
 NS_IMPL_QUERY_INTERFACE1(nsMemoryImpl, nsIMemory)
 
 NS_IMETHODIMP_(void*)
-nsMemoryImpl::Alloc(PRSize size)
+nsMemoryImpl::Alloc(size_t size)
 {
     return NS_Alloc(size);
 }
 
 NS_IMETHODIMP_(void*)
-nsMemoryImpl::Realloc(void* ptr, PRSize size)
+nsMemoryImpl::Realloc(void* ptr, size_t size)
 {
     return NS_Realloc(ptr, size);
 }
 
 NS_IMETHODIMP_(void)
 nsMemoryImpl::Free(void* ptr)
 {
     NS_Free(ptr);
@@ -153,23 +153,23 @@ nsMemoryImpl::sIsFlushing = 0;
 
 PRIntervalTime
 nsMemoryImpl::sLastFlushTime = 0;
 
 nsMemoryImpl::FlushEvent
 nsMemoryImpl::sFlushEvent;
 
 XPCOM_API(void*)
-NS_Alloc(PRSize size)
+NS_Alloc(size_t size)
 {
     return moz_xmalloc(size);
 }
 
 XPCOM_API(void*)
-NS_Realloc(void* ptr, PRSize size)
+NS_Realloc(void* ptr, size_t size)
 {
     return moz_xrealloc(ptr, size);
 }
 
 XPCOM_API(void)
 NS_Free(void* ptr)
 {
     moz_free(ptr);
--- a/xpcom/base/nsTraceRefcntImpl.cpp
+++ b/xpcom/base/nsTraceRefcntImpl.cpp
@@ -150,17 +150,17 @@ AssertActivityIsLegal()
 #  define ASSERT_ACTIVITY_IS_LEGAL PR_BEGIN_MACRO PR_END_MACRO
 #endif  // DEBUG
 
 // These functions are copied from nsprpub/lib/ds/plhash.c, with changes
 // to the functions not called Default* to free the serialNumberRecord or
 // the BloatEntry.
 
 static void *
-DefaultAllocTable(void *pool, PRSize size)
+DefaultAllocTable(void *pool, size_t size)
 {
     return PR_MALLOC(size);
 }
 
 static void
 DefaultFreeTable(void *pool, void *item)
 {
     PR_Free(item);
--- a/xpcom/base/nsUUIDGenerator.cpp
+++ b/xpcom/base/nsUUIDGenerator.cpp
@@ -35,19 +35,19 @@ nsUUIDGenerator::Init()
 {
     // We're a service, so we're guaranteed that Init() is not going
     // to be reentered while we're inside Init().
     
 #if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID)
     /* initialize random number generator using NSPR random noise */
     unsigned int seed;
 
-    PRSize bytes = 0;
+    size_t bytes = 0;
     while (bytes < sizeof(seed)) {
-        PRSize nbytes = PR_GetRandomNoise(((unsigned char *)&seed)+bytes,
+        size_t nbytes = PR_GetRandomNoise(((unsigned char *)&seed)+bytes,
                                           sizeof(seed)-bytes);
         if (nbytes == 0) {
             return NS_ERROR_FAILURE;
         }
         bytes += nbytes;
     }
 
     /* Initialize a new RNG state, and immediately switch
@@ -115,35 +115,35 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsI
     /* XXX we should be saving the return of setstate here and switching
      * back to it; instead, we use the value returned when we called
      * initstate, since older glibc's have broken setstate() return values
      */
 #ifndef ANDROID
     setstate(mState);
 #endif
 
-    PRSize bytesLeft = sizeof(nsID);
+    size_t bytesLeft = sizeof(nsID);
     while (bytesLeft > 0) {
 #ifdef ANDROID
         long rval = arc4random();
         const int mRBytes = 4;
 #else
         long rval = random();
 #endif
 
 
         PRUint8 *src = (PRUint8*)&rval;
         // We want to grab the mRBytes least significant bytes of rval, since
         // mRBytes less than sizeof(rval) means the high bytes are 0.
 #ifdef IS_BIG_ENDIAN
         src += sizeof(rval) - mRBytes;
 #endif
         PRUint8 *dst = ((PRUint8*) id) + (sizeof(nsID) - bytesLeft);
-        PRSize toWrite = (bytesLeft < mRBytes ? bytesLeft : mRBytes);
-        for (PRSize i = 0; i < toWrite; i++)
+        size_t toWrite = (bytesLeft < mRBytes ? bytesLeft : mRBytes);
+        for (size_t i = 0; i < toWrite; i++)
             dst[i] = src[i];
 
         bytesLeft -= toWrite;
     }
 
     /* Put in the version */
     id->m2 &= 0x0fff;
     id->m2 |= 0x4000;
--- a/xpcom/build/nsXPCOM.h
+++ b/xpcom/build/nsXPCOM.h
@@ -209,17 +209,17 @@ NS_NewNativeLocalFile(const nsACString &
  * Allocates a block of memory of a particular size. If the memory cannot
  * be allocated (because of an out-of-memory condition), the process aborts.
  *
  * @param size   The size of the block to allocate
  * @result       The block of memory
  * @note         This function is thread-safe.
  */
 XPCOM_API(void*)
-NS_Alloc(PRSize size);
+NS_Alloc(size_t size);
 
 /**
  * Reallocates a block of memory to a new size.
  *
  * @param ptr     The block of memory to reallocate. This block must originally
                   have been allocated by NS_Alloc or NS_Realloc
  * @param size    The new size. If 0, frees the block like NS_Free
  * @result        The reallocated block of memory
@@ -227,17 +227,17 @@ NS_Alloc(PRSize size);
  *
  * If ptr is null, this function behaves like NS_Alloc.
  * If s is the size of the block to which ptr points, the first min(s, size)
  * bytes of ptr's block are copied to the new block. If the allocation
  * succeeds, ptr is freed and a pointer to the new block is returned. If the
  * allocation fails, the process aborts.
  */
 XPCOM_API(void*)
-NS_Realloc(void* ptr, PRSize size);
+NS_Realloc(void* ptr, size_t size);
 
 /**
  * Frees a block of memory. Null is a permissible value, in which case no
  * action is taken.
  *
  * @param ptr   The block of memory to free. This block must originally have
  *              been allocated by NS_Alloc or NS_Realloc
  * @note        This function is thread-safe.
--- a/xpcom/build/nsXPCOMPrivate.h
+++ b/xpcom/build/nsXPCOMPrivate.h
@@ -63,18 +63,18 @@ typedef nsresult   (* CStringSetDataFunc
 typedef nsresult   (* CStringSetDataRangeFunc)(nsACString&, PRUint32, PRUint32, const char*, PRUint32);
 typedef nsresult   (* CStringCopyFunc)(nsACString &, const nsACString &);
 typedef void       (* CStringSetIsVoidFunc)(nsACString &, const bool);
 typedef bool       (* CStringGetIsVoidFunc)(const nsACString &);
 
 typedef nsresult   (* CStringToUTF16)(const nsACString &, nsCStringEncoding, nsAString &);
 typedef nsresult   (* UTF16ToCString)(const nsAString &, nsCStringEncoding, nsACString &);
 
-typedef void*      (* AllocFunc)(PRSize size);
-typedef void*      (* ReallocFunc)(void* ptr, PRSize size);
+typedef void*      (* AllocFunc)(size_t size);
+typedef void*      (* ReallocFunc)(void* ptr, size_t size);
 typedef void       (* FreeFunc)(void* ptr);
 
 typedef void       (* DebugBreakFunc)(PRUint32 aSeverity,
                                       const char *aStr, const char *aExpr,
                                       const char *aFile, PRInt32 aLine);
 
 typedef void       (* xpcomVoidFunc)();
 typedef void       (* LogAddRefFunc)(void*, nsrefcnt, const char*, PRUint32);
--- a/xpcom/glue/DeadlockDetector.h
+++ b/xpcom/glue/DeadlockDetector.h
@@ -198,17 +198,17 @@ private:
         ~OrderingEntry()
         {
         }
 
         CallStack mFirstSeen; // first site from which the resource appeared
         HashEntryArray mOrderedLT; // this <_o Other
     };
 
-    static void* TableAlloc(void* /*pool*/, PRSize size)
+    static void* TableAlloc(void* /*pool*/, size_t size)
     {
         return operator new(size);
     }
     static void TableFree(void* /*pool*/, void* item)
     {
         operator delete(item);
     }
     static PLHashEntry* EntryAlloc(void* /*pool*/, const void* key)
--- a/xpcom/glue/nsMemory.cpp
+++ b/xpcom/glue/nsMemory.cpp
@@ -19,17 +19,17 @@ nsMemory::HeapMinimize(bool aImmediate)
     nsCOMPtr<nsIMemory> mem;
     nsresult rv = NS_GetMemoryManager(getter_AddRefs(mem));
     NS_ENSURE_SUCCESS(rv, rv);
 
     return mem->HeapMinimize(aImmediate);
 }
 
 NS_COM_GLUE void*
-nsMemory::Clone(const void* ptr, PRSize size)
+nsMemory::Clone(const void* ptr, size_t size)
 {
     void* newPtr = NS_Alloc(size);
     if (newPtr)
         memcpy(newPtr, ptr, size);
     return newPtr;
 }
 
 NS_COM_GLUE nsIMemory*
--- a/xpcom/glue/nsMemory.h
+++ b/xpcom/glue/nsMemory.h
@@ -30,24 +30,24 @@
  * thread.
  */
 class nsMemory
 {
 public:
     static NS_HIDDEN_(void*) Alloc(size_t size)
         { return NS_Alloc(size); }
 
-    static NS_HIDDEN_(void*) Realloc(void* ptr, PRSize size)
+    static NS_HIDDEN_(void*) Realloc(void* ptr, size_t size)
         { return NS_Realloc(ptr, size); }
 
     static NS_HIDDEN_(void) Free(void* ptr)
         { NS_Free(ptr); }
 
     static NS_COM_GLUE nsresult   HeapMinimize(bool aImmediate);
-    static NS_COM_GLUE void*      Clone(const void* ptr, PRSize size);
+    static NS_COM_GLUE void*      Clone(const void* ptr, size_t size);
     static NS_COM_GLUE nsIMemory* GetGlobalMemoryService();       // AddRefs
 };
 
 /** 
  * Macro to free all elements of an XPCOM array of a given size using
  * freeFunc, then frees the array itself using nsMemory::Free().  
  *
  * Note that this macro (and its wrappers) can be used to deallocate a
--- a/xpcom/glue/standalone/nsXPCOMGlue.cpp
+++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp
@@ -403,25 +403,25 @@ XPCOM_API(nsresult)
 NS_UTF16ToCString(const nsAString &aSrc, nsCStringEncoding aDestEncoding, nsACString &aDest)
 {
     if (!xpcomFunctions.utf16ToCString)
         return NS_ERROR_NOT_INITIALIZED;
     return xpcomFunctions.utf16ToCString(aSrc, aDestEncoding, aDest);
 }
 
 XPCOM_API(void*)
-NS_Alloc(PRSize size)
+NS_Alloc(size_t size)
 {
     if (!xpcomFunctions.allocFunc)
         return nullptr;
     return xpcomFunctions.allocFunc(size);
 }
 
 XPCOM_API(void*)
-NS_Realloc(void* ptr, PRSize size)
+NS_Realloc(void* ptr, size_t size)
 {
     if (!xpcomFunctions.reallocFunc)
         return nullptr;
     return xpcomFunctions.reallocFunc(ptr, size);
 }
 
 XPCOM_API(void)
 NS_Free(void* ptr)
--- a/xpcom/stub/nsXPComStub.cpp
+++ b/xpcom/stub/nsXPComStub.cpp
@@ -191,24 +191,24 @@ NS_GetDebug(nsIDebug **result)
 EXPORT_XPCOM_API(nsresult)
 NS_GetTraceRefcnt(nsITraceRefcnt **result)
 {
   return NS_GetTraceRefcnt_P(result);
 }
 
 #undef NS_Alloc
 EXPORT_XPCOM_API(void*)
-NS_Alloc(PRSize size)
+NS_Alloc(size_t size)
 {
   return NS_Alloc_P(size);
 }
 
 #undef NS_Realloc
 EXPORT_XPCOM_API(void*)
-NS_Realloc(void* ptr, PRSize size)
+NS_Realloc(void* ptr, size_t size)
 {
   return NS_Realloc_P(ptr, size);
 }
 
 #undef NS_Free
 EXPORT_XPCOM_API(void)
 NS_Free(void* ptr)
 {