C++ use of Malloc/Realloc and Free
Kevin D. Clark
kclark at CetaceanNetworks.com
Tue Jun 24 14:16:59 EDT 2003
Jerry Feldman <gaf at blu.org> writes:
> Again, the bottom line is "use malloc(3), realloc(3), calloc(3),
> alloca(3) and free(3) in C++ at your own risk". If you know what the
> underlying implementation does, then you should have no problem. But
> also remember that on Linux, the underlying libraries can change without
> notice so that your application may not be portable accross platforms.
I think that this is a tiny bit too pessimistic.
It is possible to write portable C++ code that uses malloc() and
friends -- all without knowing what the underlying implementation
does. If you follow the rules, your code will be completely
portable. I would submit that it's not even that difficult to do
this.
malloc() and free() and new and delete etc. all do what the standards
say they should do. As long as you use these things as they are
intended, your code will be fine.
Regards,
--kevin
--
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc
More information about the Discuss
mailing list