UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2008-01-07 03:49 PM

niek
Member
Registered: 2006-12-24
Posts: 109

Re: memory

Hi,

You guys might remember me as the guy who should learn C in stead of asking his ass of here .

Well, my biggest point where pointers. And I got the whole picture now .

One thing isn't clear for me right now.

Let's say I've a program, function main() calls another function, let's call it foo().

The foo() function is a large function, and declares a lot of memory.
Like:

char var[some number];

and

char *anotherVar;
anotherVar = malloc(another number);

It does it quite a lot .

When I call the return command in that function, the function stops, and it will go to main() and execute the code after that function call .

Right, eh ? Doesn't sound too special. Except one lill' question of mine:

Does the memory, when the function ends (returns), become available ? Or will it be free()'d when the main() function ends ? or never ? or .. ?

Best Regards,
Niek van der Steen

Offline

#2 2008-01-07 04:32 PM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: memory

Offline

#3 2008-01-07 04:35 PM

niek
Member
Registered: 2006-12-24
Posts: 109

Re: memory

Okay .

That's clear .
Thanx!

But how does the story go with memory not allocated with malloc, but like this:

char var[12];

?

Offline

#4 2008-01-07 04:40 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: memory

Offline

Board footer

Powered by FluxBB