OSDN Git Service

For the serialization context, no fifo initialization is necessary.
authorAlex Sakhartchouk <alexst@google.com>
Thu, 14 Jul 2011 00:32:05 +0000 (17:32 -0700)
committerAlex Sakhartchouk <alexst@google.com>
Thu, 14 Jul 2011 00:32:05 +0000 (17:32 -0700)
On shutdown it was attempting to free uninitialized memory.

Change-Id: I9141be5a51253f87f21594ae38f7e653f9e69c6c

libs/rs/rsContext.cpp
libs/rs/rsLocklessFifo.cpp
libs/rs/rsThreadIO.cpp

index 44e9d89..4f469e1 100644 (file)
@@ -340,10 +340,6 @@ Context::Context() {
 Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc) {
     Context * rsc = new Context();
 
-    // Temporary to avoid breaking the tools
-    if (!dev) {
-        return rsc;
-    }
     if (!rsc->initContext(dev, sc)) {
         delete rsc;
         return NULL;
index 70b7278..7023a1f 100644 (file)
 using namespace android;
 using namespace android::renderscript;
 
-LocklessCommandFifo::LocklessCommandFifo() {
+LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0) {
 }
 
 LocklessCommandFifo::~LocklessCommandFifo() {
     if (!mInShutdown) {
         shutdown();
     }
-    free(mBuffer);
+    if (mBuffer) {
+        free(mBuffer);
+    }
 }
 
 void LocklessCommandFifo::shutdown() {
index ab164c3..1c8b89c 100644 (file)
@@ -21,8 +21,7 @@
 using namespace android;
 using namespace android::renderscript;
 
-ThreadIO::ThreadIO() {
-    mToCore.init(16 * 1024);
+ThreadIO::ThreadIO() : mUsingSocket(false) {
 }
 
 ThreadIO::~ThreadIO() {
@@ -30,6 +29,7 @@ ThreadIO::~ThreadIO() {
 
 void ThreadIO::init(bool useSocket) {
     mUsingSocket = useSocket;
+    mToCore.init(16 * 1024);
 
     if (mUsingSocket) {
         mToClientSocket.init();