Skip to main content
GameDev.net gamedev.net
🔒 Locked

STL with BREW on cellphones

Started by StaticReality Jun 23, 2005 at 8:54 PM 2 replies 950+ views
Original Post
StaticReality
StaticReality
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
Alan Kemp
Alan Kemp
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
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Sneftel
Sneftel
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.
StaticReality
StaticReality
Thanks, Sneftel. That was what I wanted to know. I thought that a custom allocator would be needed, I just wasn't sure that it was possible.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.