MathWorks Interview Question

what precaution should we take when using malloc.

Interview Answer

Anonymous

Apr 2, 2013

Make sure to call free() when you use malloc() or calloc(). Don't reassign pointer which points to allocated memory location without free()ing it first i.e. don't lose the reference. Be careful when using realloc(). Do not use the same pointer for input & output parameters.