Hallo
Experts,
see the two declarations .....
i) int i;
ii)p=(int*)malloc(size of(int));
Both of this functions used here to allocate the memory .But in case of the malloc ,we use then the free(p),But not for the case of int i,,,,,,,,,,,,,,,,,,,,,,,,
Why? Please REPLY....................See u again...........
from
TANGO
|
Team Leader
|
![]() |
| 10May2006,11:31 | #2 |
|
Through malloc you achieve dynamic memory allocation and dynamically allocated object remains allocated until it is deallocated explicitly, either by the programmer or by a garbage collector.
Static memory allocation refers to the process of allocating memory at compile-time before the associated program is executed. So to summarize if you allocate the memory you need to be freeing it up or if compiler allocates it for you, you dont need to be freeing it up. |
|
Contributor
|
|
| 10May2006,15:47 | #3 |
|
Quote:
Originally Posted by Tango Issac Debian Code:
int i; Quote:
Originally Posted by Tango Issac Debian Don't even think of using free on statically allocated memory. It will most probably be leading to crashing of program. |
