RH> For instance, I was wondering if it were safe to pass a
RH> NULL pointer to strdup, which would allow me to write
RH> something like
RH> TExample::TExample(const char *s)
RH> {
RH> this->s = strdup(s);
RH> }
RH> without having to check for s being NULL first.
RH> Neither Borland's online help nor Tom Swan's function
RH> reference said one way or the other, so I had to dig
RH> into the RTL source to find out it *wasn't* safe, at
RH> least not on my compiler.
RH> I'm assuming the standard would have explicitly told me so.
I know this will sound silly, but why would you want to use
strdup() in C++?? The string class IS safe, and easier to use.
Where TExample.s is defined as a class of type String:
TExample::TExample(const char *s) { this->s = s; }
It doesn't get any more simple than this.
I know it's beside the point, which is documentation for
the RTL functions, but the Class Libraries often provide
safe, and often superior, support for many data functions.
> ] So far, nobody has ever wanted to ride the Unicorn twice....
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
|