Moving nsEmbedString to mozilla/string. r=cls

This commit is contained in:
dougt%netscape.com 2003-01-14 03:37:34 +00:00
parent 22b856cac4
commit c987d07f19
13 changed files with 1760 additions and 2 deletions

View File

@ -558,6 +558,8 @@ string/Makefile
string/obsolete/Makefile
string/public/Makefile
string/src/Makefile
string/embed/Makefile
string/embed/standalone/Makefile
xpcom/Makefile
xpcom/base/Makefile
xpcom/build/Makefile

View File

@ -27,7 +27,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src obsolete
DIRS = public src obsolete embed
#ifdef ENABLE_TESTS
#DIRS += \

101
string/embed/Makefile.in Normal file
View File

@ -0,0 +1,101 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = standalone
MODULE = embedstring
LIBRARY_NAME = embedstring_s
LOCAL_INCLUDES = \
-I$(srcdir)/../src \
-I$(srcdir)/../public \
-I$(srcdir)/../obsolete \
$(NULL)
REQUIRES = string \
xpcom \
$(NULL)
STRING_LCSRCS = \
nsAString.cpp \
nsDependentSubstring.cpp \
nsASingleFragmentString.cpp \
$(NULL)
STRING_CSRCS := $(addprefix $(topsrcdir)/string/src/, $(STRING_LCSRCS))
CPPSRCS = \
$(STRING_LCSRCS) \
nsEmbedString.cpp \
$(NULL)
SDK_HEADERS = \
nsEmbedString.h \
$(NULL)
SDK_BINARY = \
$(LIB_PREFIX)embedstring_s.$(LIB_SUFFIX) \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
# Force use of PIC
FORCE_USE_PIC = 1
GARBAGE += $(STRING_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
ifeq ($(OS_ARCH),WINNT)
GARBAGE += $(addprefix $(srcdir)/,$(STRING_LCSRCS))
endif
SRCS_IN_OBJDIR = 1
include $(topsrcdir)/config/rules.mk
export:: $(STRING_CSRCS)
$(INSTALL) $^ .
DEFINES += -DXPCOM_GLUE

View File

@ -0,0 +1,454 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a small implementation of the nsAString and nsACString.
*
* The Initial Developer of the Original Code is
* Peter Annema <jaggernaut@netscape.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include "nsEmbedString.h"
const PRUnichar gCommonEmptyBuffer[1] = { 0 };
nsEmbedString::nsEmbedString()
{
Init();
}
nsEmbedString::nsEmbedString(const char_type* aString)
{
Init();
Assign(aString);
}
nsEmbedString::nsEmbedString(const char_type* aString, size_type aLength)
{
Init();
Assign(aString, aLength);
}
nsEmbedString::nsEmbedString(const nsEmbedString& aString)
{
Init();
Assign(aString);
}
nsEmbedString::nsEmbedString(const abstract_string_type& aReadable)
{
Init();
Assign(aReadable);
}
nsEmbedString::~nsEmbedString()
{
Destroy();
}
void
nsEmbedString::Init()
{
mStr = (char_type*)gCommonEmptyBuffer;
mLength = 0;
mCapacity = 0;
}
void
nsEmbedString::Destroy()
{
Free();
}
void
nsEmbedString::Free()
{
if (OwnsBuffer())
free(mStr);
}
PRBool
nsEmbedString::Realloc(size_type aNewSize)
{
PRBool result = PR_TRUE;
if (OwnsBuffer())
{
char_type* temp = (char_type*)realloc(mStr, (aNewSize + 1) * sizeof(char_type));
if (temp)
{
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
else
{
char_type* temp = (char_type*)malloc((aNewSize + 1) * sizeof(char_type));
if (temp)
{
memcpy(temp, mStr, mLength * sizeof(char_type));
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
return result;
}
PRBool
nsEmbedString::OwnsBuffer() const
{
return mStr != (char_type*)gCommonEmptyBuffer;
}
const nsEmbedString::char_type*
nsEmbedString::GetReadableFragment(const_fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset) const
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsEmbedString::char_type*
nsEmbedString::GetWritableFragment(fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset)
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
const nsEmbedString::buffer_handle_type*
nsEmbedString::GetFlatBufferHandle() const
{
return NS_REINTERPRET_CAST(const buffer_handle_type*, 1);
}
void
nsEmbedString::SetLength(size_type aLength)
{
if (aLength > mCapacity)
GrowCapacity(aLength);
mLength = aLength;
if (mStr != (char_type*)gCommonEmptyBuffer)
AddNullTerminator();
}
void
nsEmbedString::SetCapacity(size_type aNewCapacity)
{
if (aNewCapacity)
{
if (aNewCapacity > mCapacity)
GrowCapacity(aNewCapacity);
// AddNullTerminator(); // doesn't make sense
}
else
{
Destroy();
Init();
}
}
PRBool
nsEmbedString::EnsureCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (aNewCapacity > mCapacity)
{
result = Realloc(aNewCapacity);
if (result)
AddNullTerminator();
}
return result;
}
PRBool
nsEmbedString::GrowCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (mCapacity)
{
size_type newCapacity = mCapacity;
while (newCapacity < aNewCapacity)
newCapacity <<= 1;
aNewCapacity = newCapacity;
}
nsEmbedString temp;
result = temp.EnsureCapacity(aNewCapacity);
if (result)
{
if (mLength)
temp.Assign(*this);
Free();
mStr = temp.mStr;
temp.mStr = 0;
mLength = temp.mLength;
mCapacity = temp.mCapacity;
}
return result;
}
nsEmbedCString::nsEmbedCString()
{
Init();
}
nsEmbedCString::nsEmbedCString(const char_type* aString)
{
Init();
Assign(aString);
}
nsEmbedCString::nsEmbedCString(const char_type* aString, size_type aLength)
{
Init();
Assign(aString, aLength);
}
nsEmbedCString::nsEmbedCString(const nsEmbedCString& aString)
{
Init();
Assign(aString);
}
nsEmbedCString::nsEmbedCString(const abstract_string_type& aReadable)
{
Init();
Assign(aReadable);
}
nsEmbedCString::~nsEmbedCString()
{
Destroy();
}
void
nsEmbedCString::Init()
{
mStr = (char_type*)gCommonEmptyBuffer;
mLength = 0;
mCapacity = 0;
}
void
nsEmbedCString::Destroy()
{
Free();
}
void
nsEmbedCString::Free()
{
if (OwnsBuffer())
free(mStr);
}
PRBool
nsEmbedCString::Realloc(size_type aNewSize)
{
PRBool result = PR_TRUE;
if (OwnsBuffer())
{
char_type* temp = (char_type*)realloc(mStr, (aNewSize + 1) * sizeof(char_type));
if (temp)
{
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
else
{
char_type* temp = (char_type*)malloc((aNewSize + 1) * sizeof(char_type));
if (temp)
{
memcpy(temp, mStr, mLength * sizeof(char_type));
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
return result;
}
PRBool
nsEmbedCString::OwnsBuffer() const
{
return mStr != (char_type*)gCommonEmptyBuffer;
}
const nsEmbedCString::char_type*
nsEmbedCString::GetReadableFragment(const_fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset) const
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsEmbedCString::char_type*
nsEmbedCString::GetWritableFragment(fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset)
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
const nsEmbedCString::buffer_handle_type*
nsEmbedCString::GetFlatBufferHandle() const
{
return NS_REINTERPRET_CAST(const buffer_handle_type*, 1);
}
void
nsEmbedCString::SetLength(size_type aLength)
{
if (aLength > mCapacity)
GrowCapacity(aLength);
mLength = aLength;
if (mStr != (char_type*)gCommonEmptyBuffer)
AddNullTerminator();
}
void
nsEmbedCString::SetCapacity(size_type aNewCapacity)
{
if (aNewCapacity)
{
if (aNewCapacity > mCapacity)
GrowCapacity(aNewCapacity);
// AddNullTerminator(); // doesn't make sense
}
else
{
Destroy();
Init();
}
}
PRBool
nsEmbedCString::EnsureCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (aNewCapacity > mCapacity)
{
result = Realloc(aNewCapacity);
if (result)
AddNullTerminator();
}
return result;
}
PRBool
nsEmbedCString::GrowCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (mCapacity)
{
size_type newCapacity = mCapacity;
while (newCapacity < aNewCapacity)
newCapacity <<= 1;
aNewCapacity = newCapacity;
}
nsEmbedCString temp;
result = temp.EnsureCapacity(aNewCapacity);
if (result)
{
if (mLength)
temp.Assign(*this);
Free();
mStr = temp.mStr;
temp.mStr = 0;
mLength = temp.mLength;
mCapacity = temp.mCapacity;
}
return result;
}

View File

@ -0,0 +1,148 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a small implementation of the nsAString and nsACString.
*
* The Initial Developer of the Original Code is
* Peter Annema <jaggernaut@netscape.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEmbedString_h__
#define nsEmbedString_h__
#include "nsAString.h"
class nsEmbedString : public nsAString
{
public:
typedef nsEmbedString self_type;
nsEmbedString();
nsEmbedString(const self_type& aString);
explicit nsEmbedString(const abstract_string_type&);
explicit nsEmbedString(const char_type*);
nsEmbedString(const char_type*, size_type);
virtual ~nsEmbedString();
virtual const char_type* get() const { return mStr; }
virtual size_type Length() const { return mLength; }
void SetLength(size_type aLength);
void SetCapacity(size_type aNewCapacity);
nsEmbedString& operator=(const self_type& aString) { Assign(aString); return *this; }
nsEmbedString& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
nsEmbedString& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
nsEmbedString& operator=(char_type aChar) { Assign(aChar); return *this; }
protected:
void Init();
void Destroy();
void Free();
PRBool EnsureCapacity(size_type);
PRBool GrowCapacity(size_type);
virtual PRBool OwnsBuffer() const;
void AddNullTerminator() { mStr[mLength] = 0; }
PRBool Realloc(size_type);
virtual const buffer_handle_type* GetFlatBufferHandle() const;
virtual const char_type* GetReadableFragment(const_fragment_type&, nsFragmentRequest, index_type) const;
virtual char_type* GetWritableFragment(fragment_type&, nsFragmentRequest, index_type);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion
void operator=(incompatible_char_type);
protected:
char_type* mStr;
size_type mLength;
size_type mCapacity;
};
class nsEmbedCString : public nsACString
{
public:
typedef nsEmbedCString self_type;
nsEmbedCString();
nsEmbedCString(const self_type& aString);
explicit nsEmbedCString(const abstract_string_type&);
explicit nsEmbedCString(const char_type*);
nsEmbedCString(const char_type*, size_type);
virtual ~nsEmbedCString();
virtual const char_type* get() const { return mStr; }
virtual size_type Length() const { return mLength; }
void SetLength(size_type aLength);
void SetCapacity(size_type aNewCapacity);
nsEmbedCString& operator=(const self_type& aString) { Assign(aString); return *this; }
nsEmbedCString& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
nsEmbedCString& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
nsEmbedCString& operator=(char_type aChar) { Assign(aChar); return *this; }
protected:
void Init();
void Destroy();
void Free();
PRBool EnsureCapacity(size_type);
PRBool GrowCapacity(size_type);
virtual PRBool OwnsBuffer() const;
void AddNullTerminator() { mStr[mLength] = 0; }
PRBool Realloc(size_type);
virtual const buffer_handle_type* GetFlatBufferHandle() const;
virtual const char_type* GetReadableFragment(const_fragment_type&, nsFragmentRequest, index_type) const;
virtual char_type* GetWritableFragment(fragment_type&, nsFragmentRequest, index_type);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion
void operator=(incompatible_char_type);
protected:
char_type* mStr;
size_type mLength;
size_type mCapacity;
};
#endif // !nsEmbedString_h__

View File

@ -0,0 +1,105 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = embedstring
LIBRARY_NAME = embedstring
LOCAL_INCLUDES = \
-I$(srcdir)/../../src \
-I$(srcdir)/../../public \
-I$(srcdir)/../../obsolete \
$(NULL)
REQUIRES = string \
xpcom \
$(NULL)
STRING_LCSRCS = \
nsAString.cpp \
nsDependentSubstring.cpp \
nsASingleFragmentString.cpp \
$(NULL)
STRING_CSRCS := $(addprefix $(topsrcdir)/string/src/, $(STRING_LCSRCS))
EMBED_STRING_LCSRCS = \
nsEmbedString.cpp \
$(NULL)
EMBED_STRING_CSRCS := $(addprefix $(topsrcdir)/string/embed/, $(EMBED_STRING_LCSRCS))
CPPSRCS = \
$(STRING_LCSRCS) \
$(EMBED_STRING_LCSRCS) \
nsEmbedStringAllocator.cpp \
$(NULL)
SDK_BINARY = \
$(LIB_PREFIX)embedstring.$(LIB_SUFFIX) \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
# Force use of PIC
FORCE_USE_PIC = 1
GARBAGE += $(STRING_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
GARBAGE += $(EMBED_STRING_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
ifeq ($(OS_ARCH),WINNT)
GARBAGE += $(addprefix $(srcdir)/,$(STRING_LCSRCS))
GARBAGE += $(addprefix $(srcdir)/,$(EMBED_STRING_LCSRCS))
endif
SRCS_IN_OBJDIR = 1
include $(topsrcdir)/config/rules.mk
export:: $(STRING_CSRCS) $(EMBED_STRING_CSRCS)
$(INSTALL) $^ .
DEFINES += -DXPCOM_GLUE

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a small implementation of the nsAString and nsACString.
*
* The Initial Developer of the Original Code is
* Peter Annema <jaggernaut@netscape.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include "nsAString.h"
template <class CharT>
class XPCOM_StringAllocator : public nsStringAllocator<CharT>
{
public:
virtual void Deallocate( CharT* ) const;
};
template <class CharT>
void
XPCOM_StringAllocator<CharT>::Deallocate( CharT* aBuffer ) const
{
free(aBuffer);
}
NS_COM
nsStringAllocator<char>&
StringAllocator_char()
{
static XPCOM_StringAllocator<char> sStringAllocator_char;
return sStringAllocator_char;
}
NS_COM
nsStringAllocator<PRUnichar>&
StringAllocator_wchar_t()
{
static XPCOM_StringAllocator<PRUnichar> sStringAllocator_wchar_t;
return sStringAllocator_wchar_t;
}

View File

@ -27,7 +27,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src obsolete
DIRS = public src obsolete embed
#ifdef ENABLE_TESTS
#DIRS += \

View File

@ -0,0 +1,101 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = standalone
MODULE = embedstring
LIBRARY_NAME = embedstring_s
LOCAL_INCLUDES = \
-I$(srcdir)/../src \
-I$(srcdir)/../public \
-I$(srcdir)/../obsolete \
$(NULL)
REQUIRES = string \
xpcom \
$(NULL)
STRING_LCSRCS = \
nsAString.cpp \
nsDependentSubstring.cpp \
nsASingleFragmentString.cpp \
$(NULL)
STRING_CSRCS := $(addprefix $(topsrcdir)/string/src/, $(STRING_LCSRCS))
CPPSRCS = \
$(STRING_LCSRCS) \
nsEmbedString.cpp \
$(NULL)
SDK_HEADERS = \
nsEmbedString.h \
$(NULL)
SDK_BINARY = \
$(LIB_PREFIX)embedstring_s.$(LIB_SUFFIX) \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
# Force use of PIC
FORCE_USE_PIC = 1
GARBAGE += $(STRING_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
ifeq ($(OS_ARCH),WINNT)
GARBAGE += $(addprefix $(srcdir)/,$(STRING_LCSRCS))
endif
SRCS_IN_OBJDIR = 1
include $(topsrcdir)/config/rules.mk
export:: $(STRING_CSRCS)
$(INSTALL) $^ .
DEFINES += -DXPCOM_GLUE

View File

@ -0,0 +1,454 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a small implementation of the nsAString and nsACString.
*
* The Initial Developer of the Original Code is
* Peter Annema <jaggernaut@netscape.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include "nsEmbedString.h"
const PRUnichar gCommonEmptyBuffer[1] = { 0 };
nsEmbedString::nsEmbedString()
{
Init();
}
nsEmbedString::nsEmbedString(const char_type* aString)
{
Init();
Assign(aString);
}
nsEmbedString::nsEmbedString(const char_type* aString, size_type aLength)
{
Init();
Assign(aString, aLength);
}
nsEmbedString::nsEmbedString(const nsEmbedString& aString)
{
Init();
Assign(aString);
}
nsEmbedString::nsEmbedString(const abstract_string_type& aReadable)
{
Init();
Assign(aReadable);
}
nsEmbedString::~nsEmbedString()
{
Destroy();
}
void
nsEmbedString::Init()
{
mStr = (char_type*)gCommonEmptyBuffer;
mLength = 0;
mCapacity = 0;
}
void
nsEmbedString::Destroy()
{
Free();
}
void
nsEmbedString::Free()
{
if (OwnsBuffer())
free(mStr);
}
PRBool
nsEmbedString::Realloc(size_type aNewSize)
{
PRBool result = PR_TRUE;
if (OwnsBuffer())
{
char_type* temp = (char_type*)realloc(mStr, (aNewSize + 1) * sizeof(char_type));
if (temp)
{
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
else
{
char_type* temp = (char_type*)malloc((aNewSize + 1) * sizeof(char_type));
if (temp)
{
memcpy(temp, mStr, mLength * sizeof(char_type));
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
return result;
}
PRBool
nsEmbedString::OwnsBuffer() const
{
return mStr != (char_type*)gCommonEmptyBuffer;
}
const nsEmbedString::char_type*
nsEmbedString::GetReadableFragment(const_fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset) const
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsEmbedString::char_type*
nsEmbedString::GetWritableFragment(fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset)
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
const nsEmbedString::buffer_handle_type*
nsEmbedString::GetFlatBufferHandle() const
{
return NS_REINTERPRET_CAST(const buffer_handle_type*, 1);
}
void
nsEmbedString::SetLength(size_type aLength)
{
if (aLength > mCapacity)
GrowCapacity(aLength);
mLength = aLength;
if (mStr != (char_type*)gCommonEmptyBuffer)
AddNullTerminator();
}
void
nsEmbedString::SetCapacity(size_type aNewCapacity)
{
if (aNewCapacity)
{
if (aNewCapacity > mCapacity)
GrowCapacity(aNewCapacity);
// AddNullTerminator(); // doesn't make sense
}
else
{
Destroy();
Init();
}
}
PRBool
nsEmbedString::EnsureCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (aNewCapacity > mCapacity)
{
result = Realloc(aNewCapacity);
if (result)
AddNullTerminator();
}
return result;
}
PRBool
nsEmbedString::GrowCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (mCapacity)
{
size_type newCapacity = mCapacity;
while (newCapacity < aNewCapacity)
newCapacity <<= 1;
aNewCapacity = newCapacity;
}
nsEmbedString temp;
result = temp.EnsureCapacity(aNewCapacity);
if (result)
{
if (mLength)
temp.Assign(*this);
Free();
mStr = temp.mStr;
temp.mStr = 0;
mLength = temp.mLength;
mCapacity = temp.mCapacity;
}
return result;
}
nsEmbedCString::nsEmbedCString()
{
Init();
}
nsEmbedCString::nsEmbedCString(const char_type* aString)
{
Init();
Assign(aString);
}
nsEmbedCString::nsEmbedCString(const char_type* aString, size_type aLength)
{
Init();
Assign(aString, aLength);
}
nsEmbedCString::nsEmbedCString(const nsEmbedCString& aString)
{
Init();
Assign(aString);
}
nsEmbedCString::nsEmbedCString(const abstract_string_type& aReadable)
{
Init();
Assign(aReadable);
}
nsEmbedCString::~nsEmbedCString()
{
Destroy();
}
void
nsEmbedCString::Init()
{
mStr = (char_type*)gCommonEmptyBuffer;
mLength = 0;
mCapacity = 0;
}
void
nsEmbedCString::Destroy()
{
Free();
}
void
nsEmbedCString::Free()
{
if (OwnsBuffer())
free(mStr);
}
PRBool
nsEmbedCString::Realloc(size_type aNewSize)
{
PRBool result = PR_TRUE;
if (OwnsBuffer())
{
char_type* temp = (char_type*)realloc(mStr, (aNewSize + 1) * sizeof(char_type));
if (temp)
{
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
else
{
char_type* temp = (char_type*)malloc((aNewSize + 1) * sizeof(char_type));
if (temp)
{
memcpy(temp, mStr, mLength * sizeof(char_type));
mStr = temp;
mCapacity = aNewSize;
}
else
result = PR_FALSE;
}
return result;
}
PRBool
nsEmbedCString::OwnsBuffer() const
{
return mStr != (char_type*)gCommonEmptyBuffer;
}
const nsEmbedCString::char_type*
nsEmbedCString::GetReadableFragment(const_fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset) const
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
nsEmbedCString::char_type*
nsEmbedCString::GetWritableFragment(fragment_type& aFragment, nsFragmentRequest aRequest, index_type aOffset)
{
switch (aRequest) {
case kFirstFragment:
case kLastFragment:
case kFragmentAt:
aFragment.mEnd = (aFragment.mStart = mStr) + mLength;
return aFragment.mStart + aOffset;
case kPrevFragment:
case kNextFragment:
default:
return 0;
}
}
const nsEmbedCString::buffer_handle_type*
nsEmbedCString::GetFlatBufferHandle() const
{
return NS_REINTERPRET_CAST(const buffer_handle_type*, 1);
}
void
nsEmbedCString::SetLength(size_type aLength)
{
if (aLength > mCapacity)
GrowCapacity(aLength);
mLength = aLength;
if (mStr != (char_type*)gCommonEmptyBuffer)
AddNullTerminator();
}
void
nsEmbedCString::SetCapacity(size_type aNewCapacity)
{
if (aNewCapacity)
{
if (aNewCapacity > mCapacity)
GrowCapacity(aNewCapacity);
// AddNullTerminator(); // doesn't make sense
}
else
{
Destroy();
Init();
}
}
PRBool
nsEmbedCString::EnsureCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (aNewCapacity > mCapacity)
{
result = Realloc(aNewCapacity);
if (result)
AddNullTerminator();
}
return result;
}
PRBool
nsEmbedCString::GrowCapacity(size_type aNewCapacity)
{
PRBool result = PR_TRUE;
if (mCapacity)
{
size_type newCapacity = mCapacity;
while (newCapacity < aNewCapacity)
newCapacity <<= 1;
aNewCapacity = newCapacity;
}
nsEmbedCString temp;
result = temp.EnsureCapacity(aNewCapacity);
if (result)
{
if (mLength)
temp.Assign(*this);
Free();
mStr = temp.mStr;
temp.mStr = 0;
mLength = temp.mLength;
mCapacity = temp.mCapacity;
}
return result;
}

View File

@ -0,0 +1,148 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a small implementation of the nsAString and nsACString.
*
* The Initial Developer of the Original Code is
* Peter Annema <jaggernaut@netscape.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsEmbedString_h__
#define nsEmbedString_h__
#include "nsAString.h"
class nsEmbedString : public nsAString
{
public:
typedef nsEmbedString self_type;
nsEmbedString();
nsEmbedString(const self_type& aString);
explicit nsEmbedString(const abstract_string_type&);
explicit nsEmbedString(const char_type*);
nsEmbedString(const char_type*, size_type);
virtual ~nsEmbedString();
virtual const char_type* get() const { return mStr; }
virtual size_type Length() const { return mLength; }
void SetLength(size_type aLength);
void SetCapacity(size_type aNewCapacity);
nsEmbedString& operator=(const self_type& aString) { Assign(aString); return *this; }
nsEmbedString& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
nsEmbedString& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
nsEmbedString& operator=(char_type aChar) { Assign(aChar); return *this; }
protected:
void Init();
void Destroy();
void Free();
PRBool EnsureCapacity(size_type);
PRBool GrowCapacity(size_type);
virtual PRBool OwnsBuffer() const;
void AddNullTerminator() { mStr[mLength] = 0; }
PRBool Realloc(size_type);
virtual const buffer_handle_type* GetFlatBufferHandle() const;
virtual const char_type* GetReadableFragment(const_fragment_type&, nsFragmentRequest, index_type) const;
virtual char_type* GetWritableFragment(fragment_type&, nsFragmentRequest, index_type);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion
void operator=(incompatible_char_type);
protected:
char_type* mStr;
size_type mLength;
size_type mCapacity;
};
class nsEmbedCString : public nsACString
{
public:
typedef nsEmbedCString self_type;
nsEmbedCString();
nsEmbedCString(const self_type& aString);
explicit nsEmbedCString(const abstract_string_type&);
explicit nsEmbedCString(const char_type*);
nsEmbedCString(const char_type*, size_type);
virtual ~nsEmbedCString();
virtual const char_type* get() const { return mStr; }
virtual size_type Length() const { return mLength; }
void SetLength(size_type aLength);
void SetCapacity(size_type aNewCapacity);
nsEmbedCString& operator=(const self_type& aString) { Assign(aString); return *this; }
nsEmbedCString& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
nsEmbedCString& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
nsEmbedCString& operator=(char_type aChar) { Assign(aChar); return *this; }
protected:
void Init();
void Destroy();
void Free();
PRBool EnsureCapacity(size_type);
PRBool GrowCapacity(size_type);
virtual PRBool OwnsBuffer() const;
void AddNullTerminator() { mStr[mLength] = 0; }
PRBool Realloc(size_type);
virtual const buffer_handle_type* GetFlatBufferHandle() const;
virtual const char_type* GetReadableFragment(const_fragment_type&, nsFragmentRequest, index_type) const;
virtual char_type* GetWritableFragment(fragment_type&, nsFragmentRequest, index_type);
private:
// NOT TO BE IMPLEMENTED
// these signatures help clients not accidentally call the wrong thing helped by C++ automatic integral promotion
void operator=(incompatible_char_type);
protected:
char_type* mStr;
size_type mLength;
size_type mCapacity;
};
#endif // !nsEmbedString_h__

View File

@ -0,0 +1,105 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = embedstring
LIBRARY_NAME = embedstring
LOCAL_INCLUDES = \
-I$(srcdir)/../../src \
-I$(srcdir)/../../public \
-I$(srcdir)/../../obsolete \
$(NULL)
REQUIRES = string \
xpcom \
$(NULL)
STRING_LCSRCS = \
nsAString.cpp \
nsDependentSubstring.cpp \
nsASingleFragmentString.cpp \
$(NULL)
STRING_CSRCS := $(addprefix $(topsrcdir)/string/src/, $(STRING_LCSRCS))
EMBED_STRING_LCSRCS = \
nsEmbedString.cpp \
$(NULL)
EMBED_STRING_CSRCS := $(addprefix $(topsrcdir)/string/embed/, $(EMBED_STRING_LCSRCS))
CPPSRCS = \
$(STRING_LCSRCS) \
$(EMBED_STRING_LCSRCS) \
nsEmbedStringAllocator.cpp \
$(NULL)
SDK_BINARY = \
$(LIB_PREFIX)embedstring.$(LIB_SUFFIX) \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
# Force use of PIC
FORCE_USE_PIC = 1
GARBAGE += $(STRING_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
GARBAGE += $(EMBED_STRING_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
ifeq ($(OS_ARCH),WINNT)
GARBAGE += $(addprefix $(srcdir)/,$(STRING_LCSRCS))
GARBAGE += $(addprefix $(srcdir)/,$(EMBED_STRING_LCSRCS))
endif
SRCS_IN_OBJDIR = 1
include $(topsrcdir)/config/rules.mk
export:: $(STRING_CSRCS) $(EMBED_STRING_CSRCS)
$(INSTALL) $^ .
DEFINES += -DXPCOM_GLUE

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a small implementation of the nsAString and nsACString.
*
* The Initial Developer of the Original Code is
* Peter Annema <jaggernaut@netscape.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include "nsAString.h"
template <class CharT>
class XPCOM_StringAllocator : public nsStringAllocator<CharT>
{
public:
virtual void Deallocate( CharT* ) const;
};
template <class CharT>
void
XPCOM_StringAllocator<CharT>::Deallocate( CharT* aBuffer ) const
{
free(aBuffer);
}
NS_COM
nsStringAllocator<char>&
StringAllocator_char()
{
static XPCOM_StringAllocator<char> sStringAllocator_char;
return sStringAllocator_char;
}
NS_COM
nsStringAllocator<PRUnichar>&
StringAllocator_wchar_t()
{
static XPCOM_StringAllocator<PRUnichar> sStringAllocator_wchar_t;
return sStringAllocator_wchar_t;
}