(too much) allocated memory

From: Stephan Sa? (Der_gruene_Punkt_at_gmx.de)
Date: 05/22/04


Date: Sat, 22 May 2004 18:03:16 +0000 (UTC)

hi newsgroup,

i wrote a c programm:

--- snip ---
void function(int a)
{
     char buf1[8];
     char buf2[8];
     char buf3[8];
}

int main(){
   function(1);
   return 0;
}

--- snap ---

i compiled it with gcc and -S flag to get the assembler
source (platform is x86):

gcc -S -o test.s test.c

the function prolouge looks like this:

pushl %ebp
movl %esp, %ebp
subl $24, %esp

all is fine, because 3*8 byte=24 byte.

but i use only two buffers:

char buf1[8];
char buf2[16];

i get the following prolouge:

pushl %ebp
movl %esp, %ebp
subl $40, %esp

i don't understand why it uses 40 bytes if only 24 are needed.

cheers,
stephan.



Relevant Pages