mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 901820 - Part 2. Remove nsCRT::strdup/nsCRT::strndup impl. r=bsmedberg
This commit is contained in:
parent
63341bc0ca
commit
9645c57fa1
@ -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) */
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -51,7 +51,6 @@ EXPORTS += [
|
||||
'nsCRT.h',
|
||||
'nsCharSeparatedTokenizer.h',
|
||||
'nsCheapSets.h',
|
||||
'nsCppSharedAllocator.h',
|
||||
'nsExpirationTracker.h',
|
||||
'nsHashPropertyBag.h',
|
||||
'nsHashtable.h',
|
||||
|
@ -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<PRUnichar> 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)
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <ctype.h>
|
||||
#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<PRUnichar> shared_allocator;
|
||||
shared_allocator.deallocate(str, 0 /*we never new or kept the size*/);
|
||||
}
|
||||
|
||||
// String to longlong
|
||||
static int64_t atoll(const char *str);
|
||||
|
||||
|
@ -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 <new> // to allow placement |new|
|
||||
|
||||
|
||||
// under MSVC shut off copious warnings about unused in-lines
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( disable: 4514 )
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
template <class T>
|
||||
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<pointer>(nsMemory::Alloc(static_cast<uint32_t>(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 <class T>
|
||||
bool
|
||||
operator==( const nsCppSharedAllocator<T>&, const nsCppSharedAllocator<T>& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
operator!=( const nsCppSharedAllocator<T>&, const nsCppSharedAllocator<T>& )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* !defined(nsCppSharedAllocator_h__) */
|
@ -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 <string.h>
|
||||
#ifdef DEBUG_rickg
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "prlog.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user