nsListenerStruct
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 96 91c1b7c9ad098a4138c70c9203c96ff5f7beb920
permissions -rw-r--r--
State as of now

diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -556,6 +556,7 @@ nsEventListenerManager::RemoveEventListe
          (!(ls->mEventType) &&
           EVENT_TYPE_DATA_EQUALS(ls->mTypeData, aTypeData)))) {
       mListeners.RemoveElementAt(i);
+      NS_GetGC()->Free(ls);
       mNoListenerForEvent = NS_EVENT_TYPE_NULL;
       mNoListenerForEventAtom = nsnull;
       break;
@@ -827,6 +828,7 @@ nsEventListenerManager::RemoveScriptEven
 
   if (ls) {
     mListeners.RemoveElementAt(PRUint32(ls - &mListeners.ElementAt(0)));
+    NS_GetGC()->Free(ls);
     mNoListenerForEvent = NS_EVENT_TYPE_NULL;
     mNoListenerForEventAtom = nsnull;
   }
diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h
--- a/content/events/src/nsEventListenerManager.h
+++ b/content/events/src/nsEventListenerManager.h
@@ -46,12 +46,16 @@
 #include "nsHashtable.h"
 #include "nsIScriptContext.h"
 #include "nsCycleCollectionParticipant.h"
+#include "nsTArray.h"
 
 class nsIDOMEvent;
 class nsIAtom;
 struct EventTypeData;
 
-typedef struct {
+struct
+  NS_GC_TYPE
+nsListenerStruct
+{
   nsRefPtr<nsIDOMEventListener> mListener;
   PRUint32                      mEventType;
   nsCOMPtr<nsIAtom>             mTypeAtom;
@@ -59,7 +63,12 @@ typedef struct {
   PRUint16                      mGroupFlags;
   PRBool                        mHandlerIsString;
   const EventTypeData*          mTypeData;
-} nsListenerStruct;
+
+  static void* operator new(size_t size, void *placement)
+  {
+    return placement;
+  }
+};
 
 /*
  * Event listener manager
diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -778,10 +778,10 @@ class nsTArray : public nsTArray_base<Al
     }
 };
 
-template<class E, PRUint32 N>
-class nsAutoTArray : public nsTArray<E> {
+template<class E, PRUint32 N, class Allocator=CAllocator>
+class nsAutoTArray : public nsTArray<E, Allocator> {
   public:
-    typedef nsTArray<E> base_type;
+    typedef nsTArray<E, Allocator> base_type;
     typedef typename base_type::Header Header;
     typedef typename base_type::elem_type elem_type;
 
@@ -802,8 +802,8 @@ class nsAutoTArray : public nsTArray<E> 
 
 // specialization for N = 0. this makes the inheritance model easier for
 // templated users of nsAutoTArray.
-template<class E>
-class nsAutoTArray<E, 0> : public nsTArray<E> {
+template<class E, class Allocator>
+class nsAutoTArray<E, 0, Allocator> : public nsTArray<E, Allocator> {
   public:
     nsAutoTArray() {}
 };
diff --git a/xpcom/glue/nsTObserverArray.h b/xpcom/glue/nsTObserverArray.h
--- a/xpcom/glue/nsTObserverArray.h
+++ b/xpcom/glue/nsTObserverArray.h
@@ -104,7 +104,7 @@ class nsAutoTObserverArray : protected n
 class nsAutoTObserverArray : protected nsTObserverArray_base {
   public:
     typedef T           elem_type;
-    typedef nsTArray<T> array_type;
+    typedef nsTArray<T, GCAllocator> array_type;
 
     nsAutoTObserverArray() {
     }