Skip to content

Commit 69a3ce1

Browse files
committed
libutils cleanup
Change-Id: Ic069539338ba4097dba9399904f02bbd0296c20e
1 parent 5e80cac commit 69a3ce1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

libs/androidfw/AssetManager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ namespace {
9898

9999
return path;
100100
}
101+
102+
/*
103+
* Like strdup(), but uses C++ "new" operator instead of malloc.
104+
*/
105+
static char* strdupNew(const char* str)
106+
{
107+
char* newStr;
108+
int len;
109+
110+
if (str == NULL)
111+
return NULL;
112+
113+
len = strlen(str);
114+
newStr = new char[len+1];
115+
memcpy(newStr, str, len+1);
116+
117+
return newStr;
118+
}
101119
}
102120

103121
/*

0 commit comments

Comments
 (0)