cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
c/C++ dynamic memory - compatible?
c/C++ dynamic memory - compatible?
Jul 13, 2012 at 9:30pm UTC
Lowest0ne
(1536)
If I have a function in a library that uses
malloc
, is it acceptable for me to use
delete
to free it? Not sure things happen like that, but still...
Jul 13, 2012 at 9:32pm UTC
naraku9333
(2163)
Probably not, malloc/free don't invoke the ctor/dtor while new/delete do.
Jul 13, 2012 at 9:41pm UTC
Cubbi
(4774)
malloc
is guaranteed to never call
new
, and
delete
is only guaranteed to work with pointers obtained from
new
. So, no.
Topic archived. No new replies allowed.