зеркало из https://github.com/mozilla/pjs.git
Bug 677079 - Part j: Stop using js::ContextAllocPolicy in ListenerManager.cpp; r=bent+sfink
This commit is contained in:
Родитель
74616455a4
Коммит
0844833fbd
|
@ -40,8 +40,8 @@
|
|||
|
||||
#include "ListenerManager.h"
|
||||
|
||||
#include "jsalloc.h"
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/Vector.h"
|
||||
|
||||
|
@ -317,6 +317,25 @@ ListenerManager::GetEventListener(JSContext* aCx, JSString* aType,
|
|||
return true;
|
||||
}
|
||||
|
||||
class ExternallyUsableContextAllocPolicy
|
||||
{
|
||||
JSContext *const cx;
|
||||
|
||||
public:
|
||||
ExternallyUsableContextAllocPolicy(JSContext *cx) : cx(cx) {}
|
||||
JSContext *context() const { return cx; }
|
||||
void *malloc_(size_t bytes) {
|
||||
JSAutoRequest ar(cx);
|
||||
return JS_malloc(cx, bytes);
|
||||
}
|
||||
void *realloc_(void *p, size_t oldBytes, size_t bytes) {
|
||||
JSAutoRequest ar(cx);
|
||||
return JS_realloc(cx, p, bytes);
|
||||
}
|
||||
void free_(void *p) { JS_free(cx, p); }
|
||||
void reportAllocOverflow() const { JS_ReportAllocationOverflow(cx); }
|
||||
};
|
||||
|
||||
bool
|
||||
ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||
JSObject* aEvent, bool* aPreventDefaultCalled)
|
||||
|
@ -368,8 +387,8 @@ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
|||
return true;
|
||||
}
|
||||
|
||||
js::ContextAllocPolicy ap(aCx);
|
||||
js::Vector<jsval, 10, js::ContextAllocPolicy> listeners(ap);
|
||||
ExternallyUsableContextAllocPolicy ap(aCx);
|
||||
js::Vector<jsval, 10, ExternallyUsableContextAllocPolicy> listeners(ap);
|
||||
|
||||
for (PRCList* elem = PR_NEXT_LINK(&collection->mListenerHead);
|
||||
elem != &collection->mListenerHead;
|
||||
|
|
Загрузка…
Ссылка в новой задаче