Anthony Roberts <ac*************************@ucalgary.ca> writes:
It returns a char*... but where is the buffer? free() prints a debug
message saying it wasn't allocated when I try to free it. That implies
that there's a buffer somewhere managed by someone else. I'm okay with
that, but it would be a bit weird.
The man pages on OpenBSD 3.4 and MacOS 10.3 don't say anything about
it... and OpenBSD would have a paragraph on the issue if it was a
problem. But I'm still confused, so I'd be a happy man if anyone could
confirm that the buffer isn't my problem.
The inet_ntoa() function is not defined by the C standard. You'll
probably get better information in comp.unix.programmer.
In general, it's fairly common for functions that return strings to
return a pointer to a static buffer; the buffer is overwritten by
subsequent calls. (This can cause difficulties for multi-threaded
programs, but the C standard doesn't concern itself with
multi-threading.) I don't know whether inet_ntoa() does this.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"