eliminate nsCRT::strlen for char* strings (part 5), bug 124536 r=dp sr=brendan

This commit is contained in:
cathleen%netscape.com 2002-02-20 06:38:38 +00:00
Родитель 5d834eec72
Коммит 8baf662f08
15 изменённых файлов: 50 добавлений и 50 удалений

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

@ -288,7 +288,7 @@ nsHttpAuthNode::GetAuthEntryForPath(const char *path,
break;
}
}
else if (!nsCRT::strncmp(path, entry->Path(), nsCRT::strlen(entry->Path()))) {
else if (!nsCRT::strncmp(path, entry->Path(), (unsigned int)strlen(entry->Path()))) {
*result = entry;
break;
}

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

@ -1619,7 +1619,7 @@ nsTraceRefcnt::LoadLibrarySymbols(const char* aLibraryName,
if (ok) {
const char* baseName = aLibraryName;
// just get the base name of the library if a full path was given:
PRInt32 len = nsCRT::strlen(aLibraryName);
PRInt32 len = strlen(aLibraryName);
for (PRInt32 i = len - 1; i >= 0; i--) {
if (aLibraryName[i] == '\\') {
baseName = &aLibraryName[i + 1];

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

@ -1619,7 +1619,7 @@ nsTraceRefcnt::LoadLibrarySymbols(const char* aLibraryName,
if (ok) {
const char* baseName = aLibraryName;
// just get the base name of the library if a full path was given:
PRInt32 len = nsCRT::strlen(aLibraryName);
PRInt32 len = strlen(aLibraryName);
for (PRInt32 i = len - 1; i >= 0; i--) {
if (aLibraryName[i] == '\\') {
baseName = &aLibraryName[i + 1];

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

@ -2321,9 +2321,9 @@ MakeRegistryName(const char *aDllName, const char *prefix, char **regName)
{
char *registryName;
PRUint32 len = nsCRT::strlen(prefix);
PRUint32 len = strlen(prefix);
PRUint32 registryNameLen = nsCRT::strlen(aDllName) + len;
PRUint32 registryNameLen = strlen(aDllName) + len;
registryName = (char *)nsMemory::Alloc(registryNameLen + 1);
// from here on it, we want len sans terminating NUL

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

@ -551,7 +551,7 @@ nsCStringKey::nsCStringKey(const char* str, PRInt32 strLen, Ownership own)
{
NS_ASSERTION(mStr, "null string key");
if (mStrLen == PRUint32(-1))
mStrLen = nsCRT::strlen(str);
mStrLen = strlen(str);
#ifdef DEBUG
mKeyType = CStringKey;
#endif
@ -607,7 +607,7 @@ nsCStringKey::nsCStringKey(nsIObjectInputStream* aStream, nsresult *aResult)
{
nsresult rv = aStream->ReadStringZ(&mStr);
if (NS_SUCCEEDED(rv))
mStrLen = nsCRT::strlen(mStr);
mStrLen = strlen(mStr);
*aResult = rv;
MOZ_COUNT_CTOR(nsCStringKey);
}

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

@ -74,7 +74,7 @@ nsStaticCaseInsensitiveNameTable::Init(const char* Names[], PRInt32 Count)
for (PRInt32 index = 0; index < Count; ++index) {
char* raw = (char*) Names[index];
PRUint32 len = nsCRT::strlen(raw);
PRUint32 len = strlen(raw);
#ifdef DEBUG
{
// verify invarients of contents

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

@ -152,7 +152,7 @@ NS_IMETHODIMP nsSupportsStringImpl::GetData(char **aData)
NS_IMETHODIMP nsSupportsStringImpl::SetData(const char *aData)
{
return SetDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData);
return SetDataWithLength(aData ? strlen(aData) : 0, aData);
}
NS_IMETHODIMP nsSupportsStringImpl::ToString(char **_retval)
@ -193,7 +193,7 @@ NS_IMETHODIMP nsSupportsStringImpl::SetDataWithLength(PRUint32 aLength,
NS_IMETHODIMP nsSupportsStringImpl::AdoptData(char *aData)
{
return AdoptDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData);
return AdoptDataWithLength(aData ? strlen(aData) : 0, aData);
}
NS_IMETHODIMP nsSupportsStringImpl::AdoptDataWithLength(PRUint32 aLength,
@ -368,7 +368,7 @@ NS_IMETHODIMP nsSupportsPRBoolImpl::ToString(char **_retval)
NS_ASSERTION(_retval, "Bad pointer");
const char * str = mData ? "true" : "false";
char* result = (char*) nsMemory::Clone(str,
(nsCRT::strlen(str)+1)*sizeof(char));
(strlen(str)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -431,7 +431,7 @@ NS_IMETHODIMP nsSupportsPRUint8Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%u", (PRUint16) mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -479,7 +479,7 @@ NS_IMETHODIMP nsSupportsPRUint16Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%u", (int) mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -527,7 +527,7 @@ NS_IMETHODIMP nsSupportsPRUint32Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%lu", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -575,7 +575,7 @@ NS_IMETHODIMP nsSupportsPRUint64Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%llu", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -623,7 +623,7 @@ NS_IMETHODIMP nsSupportsPRTimeImpl::ToString(char **_retval)
PR_snprintf(buf, size, "%llu", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -719,7 +719,7 @@ NS_IMETHODIMP nsSupportsPRInt16Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%d", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -767,7 +767,7 @@ NS_IMETHODIMP nsSupportsPRInt32Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%ld", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -815,7 +815,7 @@ NS_IMETHODIMP nsSupportsPRInt64Impl::ToString(char **_retval)
PR_snprintf(buf, size, "%lld", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -863,7 +863,7 @@ NS_IMETHODIMP nsSupportsFloatImpl::ToString(char **_retval)
PR_snprintf(buf, size, "%f", (double) mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -911,7 +911,7 @@ NS_IMETHODIMP nsSupportsDoubleImpl::ToString(char **_retval)
PR_snprintf(buf, size, "%f", mData);
char* result = (char*) nsMemory::Clone(buf,
(nsCRT::strlen(buf)+1)*sizeof(char));
(strlen(buf)+1)*sizeof(char));
*_retval = result;
return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

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

@ -666,7 +666,7 @@ static int cvt_s(SprintfState *ss, const char *s, int width,
PRUnichar *retbuf = nsnull;
if (s) {
retbuf = UTF8ToUCS2(s, nsCRT::strlen(s), buf, 256);
retbuf = UTF8ToUCS2(s, strlen(s), buf, 256);
if(nsnull == retbuf) {
return -1;
}

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

@ -1195,7 +1195,7 @@ nsVariant::SetFromString(nsDiscriminatedUnion* data, const char *aValue)
DATA_SETTER_PROLOGUE(data);
if(!aValue)
return NS_ERROR_NULL_POINTER;
return SetFromStringWithSize(data, nsCRT::strlen(aValue), aValue);
return SetFromStringWithSize(data, strlen(aValue), aValue);
}
/* static */ nsresult
nsVariant::SetFromWString(nsDiscriminatedUnion* data, const PRUnichar *aValue)

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

@ -77,7 +77,7 @@ NS_COM char* nsEscape(const char * str, nsEscapeMask mask)
{
if(!str)
return NULL;
return nsEscapeCount(str, (PRInt32)nsCRT::strlen(str), mask, NULL);
return nsEscapeCount(str, (PRInt32)strlen(str), mask, NULL);
}
//----------------------------------------------------------------------------------------
@ -204,7 +204,7 @@ NS_COM PRInt32 nsUnescapeCount(char * str)
NS_COM char *
nsEscapeHTML(const char * string)
{
char *rv = (char *) nsMemory::Alloc(nsCRT::strlen(string)*6 + 1); /* The +1 is for the trailing null! */
char *rv = (char *) nsMemory::Alloc(strlen(string)*6 + 1); /* The +1 is for the trailing null! */
char *ptr = rv;
if(rv)

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

@ -83,7 +83,7 @@ nsSimpleCharString::nsSimpleCharString(const char* inString)
: mData(nsnull)
{
if (inString)
CopyFrom(inString, nsCRT::strlen(inString));
CopyFrom(inString, strlen(inString));
} // nsSimpleCharString::nsSimpleCharString
//----------------------------------------------------------------------------------------
@ -122,7 +122,7 @@ void nsSimpleCharString::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
if (inString)
CopyFrom(inString, nsCRT::strlen(inString));
CopyFrom(inString, strlen(inString));
else
SetToEmpty();
} // nsSimpleCharString::operator =
@ -155,7 +155,7 @@ void nsSimpleCharString::operator += (const char* inOther)
{
if (!inOther)
return;
int newLength = Length() + nsCRT::strlen(inOther);
int newLength = Length() + strlen(inOther);
ReallocData(newLength);
strcat(mData->mString, inOther);
} // nsSimpleCharString::operator =
@ -178,7 +178,7 @@ void nsSimpleCharString::Catenate(const char* inString1, const char* inString2)
*this += inString1;
return;
}
int newLength = Length() + nsCRT::strlen(inString1) + nsCRT::strlen(inString2);
int newLength = Length() + strlen(inString1) + strlen(inString2);
ReallocData(newLength);
strcat(mData->mString, inString1);
strcat(mData->mString, inString2);
@ -216,7 +216,7 @@ void nsSimpleCharString::Unescape()
if (!mData)
return;
nsUnescape(mData->mString);
mData->mLength = nsCRT::strlen(mData->mString);
mData->mLength = strlen(mData->mString);
} // nsSimpleCharString::Unescape
@ -357,7 +357,7 @@ void nsSimpleCharString::LeafReplace(char inSeparator, const char* inLeafName)
PRUint32 savedLastSeparatorOffset = (lastSeparator - chars);
int newLength =
(lastSeparator - chars) + nsCRT::strlen(inLeafName) + (trailingSeparator != 0);
(lastSeparator - chars) + strlen(inLeafName) + (trailingSeparator != 0);
ReallocData(newLength);
chars = mData->mString; // it might have moved.
@ -457,7 +457,7 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
*/
if (pathCopy[0] == '/' && pathCopy[2] == '|')
{
char* startDir = (char*)PR_Malloc(nsCRT::strlen(pathCopy) + 2);
char* startDir = (char*)PR_Malloc(strlen(pathCopy) + 2);
strcpy(startDir, pathCopy);
strcat(startDir, "/");
@ -908,8 +908,8 @@ void nsFileSpec::MakeUnique()
*lastDot = '\0'; // strip suffix and dot.
}
const int kMaxRootLength
= nsFileSpecHelpers::kMaxCoreLeafNameLength - nsCRT::strlen(suffix) - 1;
if ((int)nsCRT::strlen(leafName) > (int)kMaxRootLength)
= nsFileSpecHelpers::kMaxCoreLeafNameLength - strlen(suffix) - 1;
if ((int)strlen(leafName) > (int)kMaxRootLength)
leafName[kMaxRootLength] = '\0';
for (short indx = 1; indx < 1000 && Exists(); indx++)
{
@ -1260,7 +1260,7 @@ nsNSPRPath::operator const char*() const
modifiedNSPRPath[1] = ':';
// Remove the ending separator only if it is not the last separator
int len = nsCRT::strlen(modifiedNSPRPath);
int len = strlen(modifiedNSPRPath);
if (modifiedNSPRPath[len - 1 ] == '/' && modifiedNSPRPath[len - 2 ] != ':')
modifiedNSPRPath[len - 1 ] = '\0';
}

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

@ -138,8 +138,8 @@ static T* ConvertBreaks(const T* inSrc, PRInt32& ioLen, const char* srcBreak, co
return resultString;
}
PRInt32 srcBreakLen = nsCRT::strlen(srcBreak);
PRInt32 destBreakLen = nsCRT::strlen(destBreak);
PRInt32 srcBreakLen = strlen(srcBreak);
PRInt32 destBreakLen = strlen(destBreak);
// handle the easy case, where the string length does not change, and the
// breaks are only 1 char long, i.e. CR <-> LF
@ -245,7 +245,7 @@ static T* ConvertUnknownBreaks(const T* inSrc, PRInt32& ioLen, const char* destB
const T* src = inSrc;
const T* srcEnd = inSrc + ioLen; // includes null, if any
PRInt32 destBreakLen = nsCRT::strlen(destBreak);
PRInt32 destBreakLen = strlen(destBreak);
PRInt32 finalLen = 0;
while (src < srcEnd)
@ -332,7 +332,7 @@ char* nsLinebreakConverter::ConvertLineBreaks(const char* aSrc,
NS_ASSERTION(aDestBreaks != eLinebreakAny, "Invalid parameter");
if (!aSrc) return nsnull;
PRInt32 sourceLen = (aSrcLen == kIgnoreLen) ? nsCRT::strlen(aSrc) + 1 : aSrcLen;
PRInt32 sourceLen = (aSrcLen == kIgnoreLen) ? strlen(aSrc) + 1 : aSrcLen;
char* resultString;
if (aSrcBreaks == eLinebreakAny)
@ -358,15 +358,15 @@ nsresult nsLinebreakConverter::ConvertLineBreaksInSitu(char **ioBuffer, ELinebre
NS_ASSERTION(aDestBreaks != eLinebreakAny, "Invalid parameter");
PRInt32 sourceLen = (aSrcLen == kIgnoreLen) ? nsCRT::strlen(*ioBuffer) + 1 : aSrcLen;
PRInt32 sourceLen = (aSrcLen == kIgnoreLen) ? strlen(*ioBuffer) + 1 : aSrcLen;
// can we convert in-place?
const char* srcBreaks = GetLinebreakString(aSrcBreaks);
const char* dstBreaks = GetLinebreakString(aDestBreaks);
if ( (aSrcBreaks != eLinebreakAny) &&
(nsCRT::strlen(srcBreaks) == 1) &&
(nsCRT::strlen(dstBreaks) == 1) )
(strlen(srcBreaks) == 1) &&
(strlen(dstBreaks) == 1) )
{
ConvertBreaksInSitu(*ioBuffer, sourceLen, *srcBreaks, *dstBreaks);
if (outLen)
@ -433,8 +433,8 @@ nsresult nsLinebreakConverter::ConvertUnicharLineBreaksInSitu(PRUnichar **ioBuff
const char* dstBreaks = GetLinebreakString(aDestBreaks);
if ( (aSrcBreaks != eLinebreakAny) &&
(nsCRT::strlen(srcBreaks) == 1) &&
(nsCRT::strlen(dstBreaks) == 1) )
(strlen(srcBreaks) == 1) &&
(strlen(dstBreaks) == 1) )
{
ConvertBreaksInSitu(*ioBuffer, sourceLen, *srcBreaks, *dstBreaks);
if (outLen)

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

@ -88,9 +88,9 @@ nsLocalFile::CreateUnique(PRUint32 type, PRUint32 attributes)
}
// 27 should work on Macintosh, Unix, and Win32.
const int maxRootLength = 27 - nsCRT::strlen(suffix) - 1;
const int maxRootLength = 27 - strlen(suffix) - 1;
if ((int)nsCRT::strlen(leafName) > (int)maxRootLength)
if ((int)strlen(leafName) > (int)maxRootLength)
leafName[maxRootLength] = '\0';
for (short indx = 1; indx < 10000; indx++)

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

@ -562,7 +562,7 @@ nsPipe::nsPipeInputStream::Search(const char *forString,
const char* bufSeg1;
PRUint32 bufSegLen1;
PRUint32 segmentPos = 0;
PRUint32 strLen = nsCRT::strlen(forString);
PRUint32 strLen = strlen(forString);
rv = pipe->GetReadSegment(segmentPos, &bufSeg1, &bufSegLen1);
if (NS_FAILED(rv) || bufSegLen1 == 0) {

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

@ -126,7 +126,7 @@ TestPipe(nsIInputStream* in, nsIOutputStream* out)
for (PRUint32 i = 0; i < ITERATIONS; i++) {
PRUint32 writeCount;
char* buf = PR_smprintf("%d %s", i, kTestPattern);
rv = out->Write(buf, nsCRT::strlen(buf), &writeCount);
rv = out->Write(buf, strlen(buf), &writeCount);
if (gTrace) {
printf("wrote: ");
for (PRUint32 j = 0; j < writeCount; j++) {
@ -237,7 +237,7 @@ TestShortWrites(nsIInputStream* in, nsIOutputStream* out)
for (PRUint32 i = 0; i < ITERATIONS; i++) {
PRUint32 writeCount;
char* buf = PR_smprintf("%d %s", i, kTestPattern);
PRUint32 len = nsCRT::strlen(buf);
PRUint32 len = strlen(buf);
len = len * rand() / RAND_MAX;
len = PR_MAX(1, len);
rv = out->Write(buf, len, &writeCount);
@ -489,7 +489,7 @@ TestChainedPipes()
for (PRUint32 i = 0; i < ITERATIONS; i++) {
PRUint32 writeCount;
char* buf = PR_smprintf("%d %s", i, kTestPattern);
PRUint32 len = nsCRT::strlen(buf);
PRUint32 len = strlen(buf);
len = len * rand() / RAND_MAX;
len = PR_MAX(1, len);
rv = out1->Write(buf, len, &writeCount);