Leak Society - The Home Of Nulled Resources.
Forum Beta v1 Now Live!
Stack :)
Thead Owner : Houga, Category : Everything Coding, 4 Comment, 75 Read
Viewers: 1 Guest(s)
Member
***
68
Messages
29
Threads
0
Rep
4 Years of Service
08-10-2014, 10:46 PM
#1
The stack is a "downward growing‟ section of each program. This means that it starts at a high memory address and, when data is added onto it, it automatically allocates lower memory addresses. It operates on a FILO basis. First In Last Out means that the first data to be put onto the stack is the last data to be taken out of the stack. Think of it like stacking plates. When you put a plate on top, that will be the first one you will use. The plates on the bottom were the first to be set down and are the last to be used. Every process has its own allocated stack space. The stack size is determined by the kernel and cannot change. All variables on the stack are allocated and deallocated automatically when stack frames are created and destroyed, No extraneous user input is required. This is called static memory allocation. An example:

Code:
#include <stdio.h> /*Includes the Standard Input/Output header */ Int double_num(int i){
Int ret = i * 2 /* ret is in double_num()’s stack frame*/
return ret; /* When the return statement is hit, the value is stored in the EAX register and returns to the saved EIP. The stack frame is destroyed */
} Int main(int argc, char **argv){
}
/* ‘num’ is created in the main() function’s stack frame */
int num = double_num(10);

As you can see by the comments, each stack frame holds its own local variables. These are stored in the stack. Upon completion of a function, the stack frame is destroyed and all data on it is deallocated. Deallocation means that the memory is now able to be used by other.
Administrators
LeakSociety Owner
*****
7,137
Messages
1,907
Threads
4
Rep
2 Weeks
08-10-2014, 10:47 PM
#2
Another great post from you man.
Keep 'em coming. :D
Forum Owner
Member
***
68
Messages
29
Threads
0
Rep
4 Years of Service
08-10-2014, 10:47 PM
#3
(08-10-2014, 10:47 PM)Malevolent Wrote: Another great post from you man.
Keep 'em coming. :D
Oh hell naw, The fingers be hurtin'.
Junior Member
**
15
Messages
1
Threads
0
Rep
4 Years of Service
08-11-2014, 11:27 AM
#4
keep up the good tuts love yo work
Member
***
68
Messages
29
Threads
0
Rep
4 Years of Service
08-11-2014, 11:29 AM
#5
(08-11-2014, 11:27 AM)piemolneus Wrote: keep up the good tuts love yo work

Just noticed the messed up formatting, I'll fix that in a bit.


Forum Jump: