This commit is contained in:
scc%netscape.com 1999-07-22 18:23:02 +00:00
Родитель 423ac3ad3b
Коммит 9508780e22
5 изменённых файлов: 36 добавлений и 8 удалений

Просмотреть файл

@ -43,6 +43,7 @@
#define _nsStr
#include "nscore.h"
#include "nsCppSharedAllocator.h"
//----------------------------------------------------------------------------------------
@ -311,7 +312,11 @@ public:
aDest.mCapacity=theNewCapacity++;
size_t theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr=new char[theSize];
// aDest.mStr=new char[theSize];
nsCppSharedAllocator<char> shared_allocator;
aDest.mStr = shared_allocator.allocate(theSize);
aDest.mOwnsBuffer=1;
return PR_TRUE;
}
@ -319,7 +324,9 @@ public:
virtual PRBool Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
delete [] aDest.mStr;
// delete [] aDest.mStr;
nsCppSharedAllocator<char> shared_allocator;
shared_allocator.deallocate(aDest.mStr, aDest.mCapacity);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;

Просмотреть файл

@ -485,7 +485,12 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRUint32 n)
PRUnichar* nsCRT::strdup(const PRUnichar* str)
{
PRUint32 len = nsCRT::strlen(str) + 1; // add one for null
PRUnichar* rslt = new PRUnichar[len];
nsCppSharedAllocator<PRUnichar> shared_allocator;
PRUnichar* rslt = shared_allocator.allocate(len);
// PRUnichar* rslt = new PRUnichar[len];
if (rslt == NULL) return NULL;
nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar));
return rslt;

Просмотреть файл

@ -23,6 +23,7 @@
#include "plstr.h"
#include "nscore.h"
#include "prtypes.h"
#include "nsCppSharedAllocator.h"
#define CR '\015'
#define LF '\012'
@ -201,7 +202,8 @@ public:
static PRUnichar* strdup(const PRUnichar* str);
static void free(PRUnichar* str) {
delete[] str;
nsCppSharedAllocator<PRUnichar> shared_allocator;
shared_allocator.deallocate(str, 0 /*we never new or kept the size*/);
}
/// Compute a hashcode for a C string

Просмотреть файл

@ -43,6 +43,7 @@
#define _nsStr
#include "nscore.h"
#include "nsCppSharedAllocator.h"
//----------------------------------------------------------------------------------------
@ -311,7 +312,11 @@ public:
aDest.mCapacity=theNewCapacity++;
size_t theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr=new char[theSize];
// aDest.mStr=new char[theSize];
nsCppSharedAllocator<char> shared_allocator;
aDest.mStr = shared_allocator.allocate(theSize);
aDest.mOwnsBuffer=1;
return PR_TRUE;
}
@ -319,7 +324,9 @@ public:
virtual PRBool Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
delete [] aDest.mStr;
// delete [] aDest.mStr;
nsCppSharedAllocator<char> shared_allocator;
shared_allocator.deallocate(aDest.mStr, aDest.mCapacity);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;

Просмотреть файл

@ -43,6 +43,7 @@
#define _nsStr
#include "nscore.h"
#include "nsCppSharedAllocator.h"
//----------------------------------------------------------------------------------------
@ -311,7 +312,11 @@ public:
aDest.mCapacity=theNewCapacity++;
size_t theSize=(theNewCapacity<<aDest.mCharSize);
aDest.mStr=new char[theSize];
// aDest.mStr=new char[theSize];
nsCppSharedAllocator<char> shared_allocator;
aDest.mStr = shared_allocator.allocate(theSize);
aDest.mOwnsBuffer=1;
return PR_TRUE;
}
@ -319,7 +324,9 @@ public:
virtual PRBool Free(nsStr& aDest){
if(aDest.mStr){
if(aDest.mOwnsBuffer){
delete [] aDest.mStr;
// delete [] aDest.mStr;
nsCppSharedAllocator<char> shared_allocator;
shared_allocator.deallocate(aDest.mStr, aDest.mCapacity);
}
aDest.mStr=0;
aDest.mOwnsBuffer=0;