Sign in to follow this  
StaticReality

STL with BREW on cellphones

Recommended Posts

I am wanting to port a small game that I have written from the PC to a phone that uses BREW v2. I realize that I have quite a bit of porting to do, but has anyone tried to edit parts of the standard template library to work with BREW? Specifically, the mallac_alloc class for allocating memory for various stl classes seems easy to modify to use BREW's MALLOC() instead of libc's malloc(). Thanks, Static

Share this post


Link to post
Share on other sites
Developing for a cell phone is worlds apart from developing for a PC. You have a tiny amount of memory, and even worse, no virtual memory support (so if you fragment your memory you are in serious trouble).

I would very, very strongly advise you to stay away from anything like stl for BREW. For strings fall back to c-style char array. Dont use lists or vectors, use arrays that are exactly the size you need them to be.

At the end of the port chances are you are going to be scrounging around looking for literary any bytes you can save in order to make your program run faster/more robustly (or maybe even at all...)

Having said that, there were some article I think on code project about either writing custom string/vector classes for BREW or adapting the STL ones. I thought I had saved links to them but I can't find them now, a google search shoudl turn them up.

Alan

Share this post


Link to post
Share on other sites
Ya know, I think BREW developers often develop unnecessarily "close to the metal". I've seen so many horrible, outdated programming practices trotted out in the name of "optimization" that should have died ten years ago.

Go ahead and use the STL. For a string or vector vector, realistically it's only about sixteen bytes extra. And if you want to use a boost::array, so much the better; IIRC it's zero bytes extra. I HAVE been on mobile projects where we ended up scrounging for a few tens of bytes, but such situations are the exception, not the rule.

Keep in mind, though, that BREW has rather baroque ideas regarding memory allocation. You may find it useful to make a custom allocator to pass to STL containers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this