Bug 1324119 - Remove the sole use of MOZALLOC_HAVE_XMALLOC. r?erahm draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 05 Dec 2017 17:45:20 +0900
changeset 707463 0faa99f1b62f22e465abe0592a1625e95728b1b7
parent 707235 e19b017880c8d71385aed453bacbe2b473757e90
child 742942 5f0a7fd7f25ab8b9338fe18cd1734d014e09e445
push id92117
push userbmo:mh+mozilla@glandium.org
push dateTue, 05 Dec 2017 08:48:12 +0000
reviewerserahm
bugs1324119
milestone59.0a1
Bug 1324119 - Remove the sole use of MOZALLOC_HAVE_XMALLOC. r?erahm When this was added, the xpcom glue was still a thing, and there was a distinction between things that would build with mozalloc available and others. There is no such distinction anymore. Anything that has access to xpcom has access to infallible allocator functions.
memory/mozalloc/mozalloc.h
xpcom/ds/nsTArray.h
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -28,18 +28,16 @@
 #if defined(__cplusplus)
 #include "mozilla/fallible.h"
 #include "mozilla/mozalloc_abort.h"
 #include "mozilla/TemplateLib.h"
 #endif
 #include "mozilla/Attributes.h"
 #include "mozilla/Types.h"
 
-#define MOZALLOC_HAVE_XMALLOC
-
 #if defined(MOZ_ALWAYS_INLINE_EVEN_DEBUG)
 #  define MOZALLOC_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG
 #elif defined(HAVE_FORCEINLINE)
 #  define MOZALLOC_INLINE __forceinline
 #else
 #  define MOZALLOC_INLINE inline
 #endif
 
--- a/xpcom/ds/nsTArray.h
+++ b/xpcom/ds/nsTArray.h
@@ -198,60 +198,28 @@ struct nsTArrayFallibleAllocator : nsTAr
   {
     return realloc(aPtr, aSize);
   }
 
   static void Free(void* aPtr) { free(aPtr); }
   static void SizeTooBig(size_t) {}
 };
 
-#if defined(MOZALLOC_HAVE_XMALLOC)
-#include "mozilla/mozalloc_abort.h"
-
 struct nsTArrayInfallibleAllocator : nsTArrayInfallibleAllocatorBase
 {
   static void* Malloc(size_t aSize) { return moz_xmalloc(aSize); }
   static void* Realloc(void* aPtr, size_t aSize)
   {
     return moz_xrealloc(aPtr, aSize);
   }
 
   static void Free(void* aPtr) { free(aPtr); }
   static void SizeTooBig(size_t aSize) { NS_ABORT_OOM(aSize); }
 };
 
-#else
-#include <stdlib.h>
-
-struct nsTArrayInfallibleAllocator : nsTArrayInfallibleAllocatorBase
-{
-  static void* Malloc(size_t aSize)
-  {
-    void* ptr = malloc(aSize);
-    if (MOZ_UNLIKELY(!ptr)) {
-      NS_ABORT_OOM(aSize);
-    }
-    return ptr;
-  }
-
-  static void* Realloc(void* aPtr, size_t aSize)
-  {
-    void* newptr = realloc(aPtr, aSize);
-    if (MOZ_UNLIKELY(!newptr && aSize)) {
-      NS_ABORT_OOM(aSize);
-    }
-    return newptr;
-  }
-
-  static void Free(void* aPtr) { free(aPtr); }
-  static void SizeTooBig(size_t aSize) { NS_ABORT_OOM(aSize); }
-};
-
-#endif
-
 // nsTArray_base stores elements into the space allocated beyond
 // sizeof(*this).  This is done to minimize the size of the nsTArray
 // object when it is empty.
 struct nsTArrayHeader
 {
   static nsTArrayHeader sEmptyHdr;
 
   uint32_t mLength;