Hi,
You asked:
JT>Just something I began wondering last night.
JT>Since it's good coding practise to free() everything
JT>allocated with malloc(), should I also free() those blocks
JT>of memory which are allocated by other functions (such as
JT>fopen())?
No. You only free() anything _you_ allocate withe malloc(). Any memory
allocated by system calls will (in a good library) be freed by the
corresponding termination call. So if fopen() allocates any memory
buffers fclose() will de-allocate them.
Officially you have no way of knowing how any specific library function
has allocated any memory it requires so there is nothing you should have
to do to reclaim it. Most library functions that require memory buffers
either use a static buffer or expect you to provide a pointer to a
suitable buffer as a function parameter.
George
* SLMR 2.1a * Wastebasket: Something to throw things near.
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)
|