Domanda di colloquio di MathWorks

what precaution should we take when using malloc.

Risposta di colloquio

Anonimo

2 apr 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.