uSTL in Android

88 views
Skip to first unread message

JayBird

unread,
Mar 12, 2009, 1:32:59 AM3/12/09
to android-ndk
Hi,

I read a number of discussions within the android google groups
related to STL, and aware that there is no STL support at this time.
However as I was searching through some the android source, it looks
like some parts of ustl-1.0 is being used here

mydroid/frameworks/base/media/libdrm/mobile2/src/util/ustl-1.0

I was wondering if someone from Google can comment on the changes and
limitations of using this modified version of uSTL as a STL
replacement?


Thanks in advance,
Jay

David Turner

unread,
Mar 12, 2009, 8:19:24 AM3/12/09
to andro...@googlegroups.com

Absolutely :-) uSTL cannot be used as a general purpose replacement for the STL
for a single reason: it uses a custom memory management scheme that doesn't comply
with the standard (also you need a set of wrapper headers to use it as a STL).

This has the drawback of not allowing to put in generic containers objects that contain
pointer to themselves (because these are not adjusted when the objects are moved
due to a dynamic reallocation). However, this custom scheme is also why uSTL generates
code that is so much smaller than the standard STL.

More information about it is available here: http://ustl.sourceforge.net/#Memblocks

We have decided that uSTL would not be the default STL implementation in Android
because it has the potential of playing bad with certain legacy code that we would like
to port to the platform in the future (we're just playing it safe at the moment).

It is used by certain components of Android. If you look at the source code, you'll
see that there are essentially several small re-implementations of the STL used by various
parts of the system. One of our goal in the future is to merge these efforts into a single
system (small) library. However, at the moment we prefer to make it clear that this is
completely independent of adding "real" STL support for third-party application using
native code through the NDK.





Thanks in advance,
Jay



JayBird

unread,
Mar 12, 2009, 9:41:53 AM3/12/09
to android-ndk
Hi Dave,

Thanks for the detail explanation:) I was a little puzzled when I saw
this code, given what I read in the previous postings.

Cheers,
Jay


On Mar 12, 7:19 am, David Turner <di...@android.com> wrote:
Reply all
Reply to author
Forward
0 new messages