nsJSONWriter-temp-finalizable
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 160 fd41ae75c7983b0c8aeff594c5c4cb25cde2ce5e
permissions -rw-r--r--
State as of now

Temporary patch: nsJSONWriter needs to be managed. I've implemented a better solution on 446132

diff --git a/dom/src/json/nsJSON.cpp b/dom/src/json/nsJSON.cpp
--- a/dom/src/json/nsJSON.cpp
+++ b/dom/src/json/nsJSON.cpp
@@ -87,7 +87,7 @@ nsJSON::Encode(nsAString &aJSON)
   // This function should only be called from JS.
   nsresult rv;
 
-  nsAutoPtr<nsJSONWriter> writer(new nsJSONWriter());
+  nsJSONWriter* writer = new nsJSONWriter();
   if (!writer)
     return NS_ERROR_OUT_OF_MEMORY;
   
@@ -172,7 +172,7 @@ nsJSON::EncodeToStream(nsIOutputStream *
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  nsAutoPtr<nsJSONWriter> writer(new nsJSONWriter(bufferedStream));
+  nsJSONWriter* writer = new nsJSONWriter(bufferedStream);
   if (!writer)
     return NS_ERROR_OUT_OF_MEMORY;
   rv = writer->SetCharset(aCharset);
diff --git a/dom/src/json/nsJSON.h b/dom/src/json/nsJSON.h
--- a/dom/src/json/nsJSON.h
+++ b/dom/src/json/nsJSON.h
@@ -55,7 +55,7 @@ class nsIURI;
 #define JSON_MAX_DEPTH  2048
 #define JSON_PARSER_BUFSIZE 1024
 
-class nsJSONWriter
+class nsJSONWriter : public XPCOMGCFinalizedObject, public MMgc::GCFinalizable
 {
 public:
   nsJSONWriter();