Why u_char* not char*
Marcus Clyne
maccaday at gmail.com
Wed Jul 15 02:02:48 MSD 2009
Hi,
merlin corey wrote:
> What's the difference in storage of these types in memory?
>
AFAIK, none - u_char is just an unsigned char. I can't see why any
system would store them differently and I'm guessing that type
conversion would be a noop on every system (though I'd be interested to
hear of any evidence otherwise).
How they are treated when representing them as numbers or when they're
involved with any kind of mathematical operations would be different,
though (in general).
The pain in using u_char* for strings vs char* is that you often have to
deal with typecasting when interacting with other functions,
reading/writing etc. It's much rarer that other functions (especially
system ones) deal with u_char's rather than char's.
I was wondering why bother with the extra hassle. I'm guessing there's
a reason why Igor chose them over char*'s, but I don't know what it is.
Cheers,
Marcus.
More information about the nginx
mailing list