OSDN Git Service

libutils cleanup
authorMathias Agopian <mathias@google.com>
Sun, 5 Aug 2012 19:38:51 +0000 (12:38 -0700)
committerMathias Agopian <mathias@google.com>
Sun, 5 Aug 2012 19:38:51 +0000 (12:38 -0700)
Change-Id: Ic069539338ba4097dba9399904f02bbd0296c20e

libs/androidfw/AssetManager.cpp

index 8d59d8e..8bd805c 100644 (file)
@@ -98,6 +98,24 @@ namespace {
 
         return path;
     }
+
+    /*
+     * Like strdup(), but uses C++ "new" operator instead of malloc.
+     */
+    static char* strdupNew(const char* str)
+    {
+        char* newStr;
+        int len;
+
+        if (str == NULL)
+            return NULL;
+
+        len = strlen(str);
+        newStr = new char[len+1];
+        memcpy(newStr, str, len+1);
+
+        return newStr;
+    }
 }
 
 /*