Bug 1423119 - 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.
--- 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;