C
CBFalconer
aj said:As usual, you guys are no help, just sticklers for details.
Thanks for the non-help.
Congratulations. Your second post attained PLONK status. A new
record here.
PLONK
aj said:As usual, you guys are no help, just sticklers for details.
Thanks for the non-help.
calls works, on Linux, it core dumps (memory dump) at the delete
call. Am I responsible for deleting the memory that gethostbyname
allocated?
I am under the impression that you don't delete anything unless you
personally "new'ed" it. Is this theory correct in this situation?
And the answer to that is implementation/function specific, youraj said:My question wasn't about "delete" or "new". My question was if I am
responsible for deallocating the pointer provided by a certain
function.
I didn't (still the proud owner of an entirely empty killfile), but othersI wasn't aware that that particular function,
gethostbyname(), isn't in the C standard. Regardless, it is still C
syntax, compiled by a C compiler. I will save future (read: all)
questions for a more appropriate newsgroup. Sorry you felt the need
to plonk me.
aj said:Acknowledged. Except you guys aren't stockboys. Stockboys don't know
what to do about the flu. You hardened C types, however, have the
knowledge to provide insight into my dilemna, so I dismiss your
analogy !
Gordon said:Am I responsible for deleting the memory that gethostbyname
allocated?
*ANY* function that returns a pointer should include in its
documentation something to address this issue. Various possibilities
include (assuming the function doesn't return NULL):
(a) The pointer points into data that was passed in (e.g. strchr(),
> ... [several other categories of returned pointers]
(f) The function returns a pointer that may or may not be allocated
with malloc(), points to static data, or points into data passed
into the function, with no obvious way to tell which. You can't
risk calling free() on the resulting pointer, and you should
fire the guy who writes code like this.
What does the documentation say?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.