removed IMalloc clone and replaced it with use of nsIAllocator
git-svn-id: svn://10.0.0.236/trunk@18826 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
4174f88609
commit
9f11bbe8cc
@ -38,7 +38,6 @@ OBJS= \
|
||||
.\$(OBJDIR)\xpccontext.obj \
|
||||
.\$(OBJDIR)\xpcbogusjs.obj \
|
||||
.\$(OBJDIR)\xpcbogusii.obj \
|
||||
.\$(OBJDIR)\xpcbogusmem.obj \
|
||||
.\$(OBJDIR)\xpcinvoke.obj \
|
||||
.\$(OBJDIR)\xpcwrappedjs.obj \
|
||||
.\$(OBJDIR)\xpcwrappedjsclass.obj \
|
||||
|
||||
@ -30,21 +30,20 @@ NS_IMPL_ISUPPORTS(nsXPConnect, NS_IXPCONNECT_IID)
|
||||
|
||||
nsXPConnect* nsXPConnect::mSelf = NULL;
|
||||
|
||||
static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
|
||||
static NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
|
||||
|
||||
// static
|
||||
nsXPConnect*
|
||||
nsXPConnect::GetXPConnect()
|
||||
{
|
||||
if(mSelf)
|
||||
{
|
||||
NS_ADDREF(mSelf);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSelf = new nsXPConnect();
|
||||
if(mSelf && (!mSelf->mContextMap || !mSelf->mAllocator))
|
||||
{
|
||||
NS_RELEASE(mSelf); // XXX two line macro (bug in nsISupports.h)
|
||||
}
|
||||
}
|
||||
return mSelf;
|
||||
}
|
||||
@ -54,17 +53,20 @@ nsXPConnect::nsXPConnect()
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF_THIS();
|
||||
mContextMap = JSContext2XPCContextMap::newMap(CONTEXT_MAP_SIZE);
|
||||
mAllocator = new nsMalloc();
|
||||
|
||||
nsServiceManager::GetService(kAllocatorCID,
|
||||
kIAllocatorIID,
|
||||
(nsISupports **)&mAllocator);
|
||||
}
|
||||
|
||||
nsXPConnect::~nsXPConnect()
|
||||
{
|
||||
if(mContextMap)
|
||||
delete mContextMap;
|
||||
|
||||
if(mAllocator)
|
||||
{
|
||||
NS_RELEASE(mAllocator); // XXX two line macro (bug in nsISupports.h)
|
||||
}
|
||||
nsServiceManager::ReleaseService(kAllocatorCID, mAllocator);
|
||||
|
||||
mSelf = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Bogus implementation of nsIMalloc ('out' param mem manager). */
|
||||
|
||||
#include "xpcprivate.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMalloc, NS_IMALLOC_IID);
|
||||
|
||||
nsMalloc::nsMalloc()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
void* nsMalloc::Alloc(uint32 cb){return malloc(cb);}
|
||||
void* nsMalloc::Realloc(void *pv, uint32 cb){return realloc(pv,cb);}
|
||||
void nsMalloc::Free(void *pv) {free(pv);}
|
||||
uint32 nsMalloc::GetSize(void *pv) {return 0;}
|
||||
int32 nsMalloc::DidAlloc(void *pv) {return 1;}
|
||||
void nsMalloc::HeapMinimize(void) {}
|
||||
@ -1,53 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Temporary nsIMalloc related stuff. */
|
||||
|
||||
#ifndef xpcbogusmem_h___
|
||||
#define xpcbogusmem_h___
|
||||
|
||||
// {7BB253C0-AC2D-11d2-BA68-00805F8A5DD7}
|
||||
#define NS_IMALLOC_IID \
|
||||
{ 0x7bb253c0, 0xac2d, 0x11d2, \
|
||||
{ 0xba, 0x68, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
|
||||
|
||||
class nsIMalloc : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD_(void*) Alloc(uint32 cb) = 0;
|
||||
NS_IMETHOD_(void*) Realloc(void *pv, uint32 cb) = 0;
|
||||
NS_IMETHOD_(void) Free(void *pv) = 0;
|
||||
NS_IMETHOD_(uint32) GetSize(void *pv) = 0;
|
||||
NS_IMETHOD_(int32) DidAlloc(void *pv) = 0;
|
||||
NS_IMETHOD_(void) HeapMinimize(void) = 0;
|
||||
};
|
||||
|
||||
class nsMalloc : public nsIMalloc
|
||||
{
|
||||
public:
|
||||
nsMalloc();
|
||||
NS_DECL_ISUPPORTS;
|
||||
NS_IMETHOD_(void*) Alloc(uint32 cb);
|
||||
NS_IMETHOD_(void*) Realloc(void *pv, uint32 cb);
|
||||
NS_IMETHOD_(void) Free(void *pv);
|
||||
NS_IMETHOD_(uint32) GetSize(void *pv);
|
||||
NS_IMETHOD_(int32) DidAlloc(void *pv);
|
||||
NS_IMETHOD_(void) HeapMinimize(void);
|
||||
};
|
||||
|
||||
#endif /* xpcbogusmem_h___ */
|
||||
@ -25,6 +25,8 @@
|
||||
#include <stdlib.h>
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
#include "jshash.h"
|
||||
@ -32,7 +34,6 @@
|
||||
|
||||
#include "xpcbogusjs.h"
|
||||
#include "xpcbogusii.h"
|
||||
#include "xpcbogusmem.h"
|
||||
|
||||
extern const char* XPC_VAL_STR; // 'val' property name for out params
|
||||
|
||||
@ -78,7 +79,7 @@ public:
|
||||
|
||||
XPCContext* GetContext(JSContext* cx);
|
||||
JSContext2XPCContextMap* GetContextMap() {return mContextMap;}
|
||||
nsIMalloc* GetAllocator()
|
||||
nsIAllocator* GetAllocator()
|
||||
{
|
||||
if(mAllocator)
|
||||
NS_ADDREF(mAllocator);
|
||||
@ -93,7 +94,7 @@ private:
|
||||
private:
|
||||
static nsXPConnect* mSelf;
|
||||
JSContext2XPCContextMap* mContextMap;
|
||||
nsIMalloc* mAllocator;
|
||||
nsIAllocator* mAllocator;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user