What are the differences between malloc and new in terms of their respective mechanisms of handling memory allocation?
What are the differences between malloc and new in terms of their respective mechanisms
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
mallocdoesn’t throwbad_allocexception asnewdoes.NULL(or nullptr in c++11 and above), which isn’t necessary withnew. However,newcan be used in a way it won’t throw expections, as when functionset_new_handleris setmallocandfreedo not call object constructors and destructors, since there is no objects inC.