First off, I'm sorry if I misled you, Erik. I did not mean to imply that I have my code running on an XBox. I simply meant to say that I have been playing around with my own personal copy of DROD.
ErikH2000 wrote:
Everything should compile right now under either VC6 or G++/Linux. Trick used the current source to release DROD:AE for Linux. So I'm not sure what you mean by VC6-isms.
Good point. I'm not entirely sure what I meant by VC6-isms, either. For the moment, I'll just start describing some of the changes:
One of the things that I specifically had in mind when I wrote that was that various places in the code check the return value of "
x = new Foo();"
. According to the standard, x is always nonzero, but the statement could throw a std::bad_alloc. MSVC6, I believe, returns a null pointer if memory is exhausted. There are checks for this possibility throughout the DROD code. For my own purposes, I consider these to be clutter.
More importantly, MSVC6 allows a pointer allocated as "
x = new char[7];"
to be deleted via "
delete x;"
. I believe that this is undefined behavior according to the standard. I'm not sure what the runtime library's behavior under g++ is. (It does seem to work, but perhaps it leaks or something.) Anyway, I have been correcting these when I find them. (Often by using standard containers instead.)
In addition to these two behavioral differences, I may have been thinking of some of the stylisitic changes as "
MSVC-isms"
. For example, there may be some reason under MSVC6 to prefer a precompiler macro to an inline function. (I don't think this is the case as I think about it now, though.) The naming conventions used seem to follow those used in MFC. This could just be sloppy thinking on my part.
Anyway, I basically just wanted to let folks know that I would be pleased to see code that includes "
portability enhancements"
published, either within the official CVS, or otherwise. I don't necessarily intend to do any significant amount of work toward that end, and I certainly don't expect other people to do so, either! However, perhaps there is something easy that I can do that might encourage other people to work on such enhancements, or to entice them to publish such.
Up to this point, I have (on purpose) definitely been taking the "
lone wolf"
route. After thinking about this choice, though, I've realized that I would be pleased if I could give something back to the community, and I might have something to offer.
For example, I think that I could put together a list of individual "
delete"
vs. "
delete[]"
changes, if someone were to ask for it. Someone needs to ask, though. I don't know yet if it is an issue for anyone. Because some of the original locations that show this issue have been removed from my code, it is not a simple matter of diffing my changes. I would want any changes that are to be applied to the main CVS branch to fix the problem at hand in the simplest possible manner, without sucking in other changes.
If I find the time, I'll try to post a high-level list of other changes that I could offer, and which might be useful to other people. (Particularly if I think they might relate to portability.) Until I do that, there's no real way of knowing whether or not I do have anything useful.
Offhand, I do recall fixing a couple of SDL resource leaks. I don't recall the details at the moment, but after I go home I'll figure out what they were. I believe that there was a very minor bug somewhere involving a loop control variable not being re-initialized between two loops. These are the only other changes that I can think of that actually fix improper behavior. They don't affect portability; I'm just listing them because bug fixes are of obvious interest to other people.
I'll also attach a .tgz of my current code, in case someone has enough curiosity & bravery to look at it. (I don't know what the ettiquette here is regarding upload sizes. It's about 500k; if that's overboard, then I assume that you can just remove it, Erik.) I'm providing it as-is. DROD/Main.cpp has some unnecessary stuff relating to garbage collection that can be stripped out. The PathMap, CDbPackedVars, and DbRooms files probably best show the sorts of changes that I have made.
[Edited by wmarkham at
Local Time:12-15-2004 at 12:04 AM: said "
StretchyBuf"
when I really meant "
CDbPackedVars"
]