diff --git a/intl/uconv/ucvcn/nsGBKConvUtil.cpp b/intl/uconv/ucvcn/nsGBKConvUtil.cpp index 033b615545e9..e343306538a9 100644 --- a/intl/uconv/ucvcn/nsGBKConvUtil.cpp +++ b/intl/uconv/ucvcn/nsGBKConvUtil.cpp @@ -5,7 +5,6 @@ #include "nsGBKConvUtil.h" #include "gbku.h" -#include "nsCRT.h" #include "nsDebug.h" #define MAX_GBK_LENGTH 24066 /* (0xfe-0x80)*(0xfe-0x3f) */ //-------------------------------------------------------------------- diff --git a/xpcom/ds/moz.build b/xpcom/ds/moz.build index 01a7d07ca520..4f29be692639 100644 --- a/xpcom/ds/moz.build +++ b/xpcom/ds/moz.build @@ -51,7 +51,6 @@ EXPORTS += [ 'nsCRT.h', 'nsCharSeparatedTokenizer.h', 'nsCheapSets.h', - 'nsCppSharedAllocator.h', 'nsExpirationTracker.h', 'nsHashPropertyBag.h', 'nsHashtable.h', diff --git a/xpcom/ds/nsCRT.cpp b/xpcom/ds/nsCRT.cpp index 0e8122bbf829..07557fdeb733 100644 --- a/xpcom/ds/nsCRT.cpp +++ b/xpcom/ds/nsCRT.cpp @@ -149,24 +149,6 @@ const char* nsCRT::memmem(const char* haystack, uint32_t haystackLen, return NULL; } -PRUnichar* nsCRT::strdup(const PRUnichar* str) -{ - uint32_t len = NS_strlen(str); - return strndup(str, len); -} - -PRUnichar* nsCRT::strndup(const PRUnichar* str, uint32_t len) -{ - nsCppSharedAllocator shared_allocator; - PRUnichar* rslt = shared_allocator.allocate(len + 1); // add one for the null - // PRUnichar* rslt = new PRUnichar[len + 1]; - - if (rslt == NULL) return NULL; - memcpy(rslt, str, len * sizeof(PRUnichar)); - rslt[len] = 0; - return rslt; -} - // This should use NSPR but NSPR isn't exporting its PR_strtoll function // Until then... int64_t nsCRT::atoll(const char *str) diff --git a/xpcom/ds/nsCRT.h b/xpcom/ds/nsCRT.h index be121a21e31d..4f8bea17accc 100644 --- a/xpcom/ds/nsCRT.h +++ b/xpcom/ds/nsCRT.h @@ -10,7 +10,6 @@ #include #include "plstr.h" #include "nscore.h" -#include "nsCppSharedAllocator.h" #include "nsCRTGlue.h" #if defined(XP_WIN) || defined(XP_OS2) @@ -102,18 +101,6 @@ public: return int32_t(PL_strncmp(s1,s2,unsigned(aMaxLen))); } - static char* strdup(const char* str) { - return PL_strdup(str); - } - - static char* strndup(const char* str, uint32_t len) { - return PL_strndup(str, len); - } - - static void free(char* str) { - PL_strfree(str); - } - /** How to use this fancy (thread-safe) version of strtok: @@ -147,19 +134,6 @@ public: static const char* memmem(const char* haystack, uint32_t haystackLen, const char* needle, uint32_t needleLen); - // You must use nsCRT::free(PRUnichar*) to free memory allocated - // by nsCRT::strdup(PRUnichar*). - static PRUnichar* strdup(const PRUnichar* str); - - // You must use nsCRT::free(PRUnichar*) to free memory allocated - // by strndup(PRUnichar*, uint32_t). - static PRUnichar* strndup(const PRUnichar* str, uint32_t len); - - static void free(PRUnichar* str) { - nsCppSharedAllocator shared_allocator; - shared_allocator.deallocate(str, 0 /*we never new or kept the size*/); - } - // String to longlong static int64_t atoll(const char *str); diff --git a/xpcom/ds/nsCppSharedAllocator.h b/xpcom/ds/nsCppSharedAllocator.h deleted file mode 100644 index 275d724d7665..000000000000 --- a/xpcom/ds/nsCppSharedAllocator.h +++ /dev/null @@ -1,104 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsCppSharedAllocator_h__ -#define nsCppSharedAllocator_h__ - -#include "nsMemory.h" // for |nsMemory| -#include // to allow placement |new| - - - // under MSVC shut off copious warnings about unused in-lines -#ifdef _MSC_VER - #pragma warning( disable: 4514 ) -#endif - -#include - - -template -class nsCppSharedAllocator - /* - ...allows Standard Library containers, et al, to use our global shared - (XP)COM-aware allocator. - */ - { - public: - typedef T value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef T* pointer; - typedef const T* const_pointer; - - typedef T& reference; - typedef const T& const_reference; - - - - nsCppSharedAllocator() { } - - ~nsCppSharedAllocator() { } - - - pointer - address( reference r ) const - { - return &r; - } - - const_pointer - address( const_reference r ) const - { - return &r; - } - - pointer - allocate( size_type n, const void* /*hint*/=0 ) - { - return reinterpret_cast(nsMemory::Alloc(static_cast(n*sizeof(T)))); - } - - void - deallocate( pointer p, size_type /*n*/ ) - { - nsMemory::Free(p); - } - - void - construct( pointer p, const T& val ) - { - new (p) T(val); - } - - void - destroy( pointer p ) - { - p->~T(); - } - - size_type - max_size() const - { - return ULONG_MAX / sizeof(T); - } - - }; - - -template -bool -operator==( const nsCppSharedAllocator&, const nsCppSharedAllocator& ) - { - return true; - } - -template -bool -operator!=( const nsCppSharedAllocator&, const nsCppSharedAllocator& ) - { - return false; - } - -#endif /* !defined(nsCppSharedAllocator_h__) */ diff --git a/xpcom/glue/nsDeque.cpp b/xpcom/glue/nsDeque.cpp index 853b1fdab5b0..8f565bb563df 100644 --- a/xpcom/glue/nsDeque.cpp +++ b/xpcom/glue/nsDeque.cpp @@ -4,8 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsDeque.h" -#include "nsCRT.h" #include "nsTraceRefcnt.h" +#include #ifdef DEBUG_rickg #include #endif diff --git a/xpcom/io/nsPipe3.cpp b/xpcom/io/nsPipe3.cpp index eaec4e82d7aa..2f4b17d1e5eb 100644 --- a/xpcom/io/nsPipe3.cpp +++ b/xpcom/io/nsPipe3.cpp @@ -15,6 +15,7 @@ #include "prlog.h" #include "nsIClassInfoImpl.h" #include "nsAlgorithm.h" +#include "nsMemory.h" using namespace mozilla; diff --git a/xpcom/io/nsSegmentedBuffer.cpp b/xpcom/io/nsSegmentedBuffer.cpp index 1938fa16f834..9a5d6c972577 100644 --- a/xpcom/io/nsSegmentedBuffer.cpp +++ b/xpcom/io/nsSegmentedBuffer.cpp @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsSegmentedBuffer.h" -#include "nsCRT.h" +#include "nsMemory.h" nsresult nsSegmentedBuffer::Init(uint32_t segmentSize, uint32_t maxSize,