Hi David, David Bertoni <[EMAIL PROTECTED]> writes:
> >There are tons of places where int/long is used instead of XMLSize_t. > >While most of them are straightforward to move to XMLSize_t, there are > >places with really rotten code, for example, signed int is used to > >return length and -1 is returned to indicate an error (so this code > >is not even 32-bit safe). Such places will require more effort to > >port. > Exactly. But changing these int return types to XMLSSize_t (signed size > type) should be safe, correct? No, that's exactly the change I am afraid people would make (once it is made it will be very hard to find and fix). If you return something that can potentially require 64 bit (e.g., any kind of memory-related length or size), we should always use XMLSize_t. If you use XMLSSize_t then you effectively halve the amount of length/size that can be represented. Some people like to argue that this is not a problem since it is not realistic to have, say, more than 2^32 attributes. To this I can only say that less than 10 years ago people thought it is not realistic to have more than 4GB of memory. I don't want to go through the same process again in the next few years. > I will start on a patch to move the template collection classes from > unsigned int to XMLSize_t, which should be safe. There are also some > places where ints are used as keys for the hash tables. I believe those > should be safe to move to XMLSSize_t or XMLSize_t, as they are used in a > handful of places. Sounds good but please don't just mindlessly change signed int to XMLSSize_t. In most cases when signed int is used it is either that the original author forgot to put unsigned (yes, there are places where both int and unsigned int types are used for the same thing in the same interface) or that there is some extra information represented by the negative value (e.g., error). In the latter case the thing needs to be redesigned. I may also get to some of those containers (those that are in util/ and framework/) before you since it is easier to just fix everything than to figure out what's public and what's not. So I suggest that you give me a couple more days to finish my interface porting effort. Boris -- Boris Kolpackov, Code Synthesis Tools http://codesynthesis.com/~boris/blog Open source XML data binding for C++: http://codesynthesis.com/products/xsd Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
