Discussion
Which one is used during memory deallocation in C?
Answer: C
Correct answer: free(p);
free is the standard C deallocation function. It returns the block to the allocator, which may reuse it for a later request.
The other names belong elsewhere: delete is C++, and remove in C deletes a file rather than memory. Two conventions are worth keeping with free: passing NULL is explicitly defined to do nothing, so no guard is needed, and setting the pointer to NULL afterwards turns a later misuse into an immediate fault.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development