AllocateProgramGlobal variables
Allocation program initialization Function
The sbrk () function is used to dynamically increase the memory space.
Char * sbrk (INT incr) incr is the increase in the number of bytes.
Memory Control Block Structure
The release function of the Assignment Program.
Allocation Function of the Assignment Program
The figure between pointers is as follows:
Mem_alloc_ptr is the available range pointer returned by the malloc () function.
Thoughts:
1). The underlying programming skills of memory allocation are forced type conversion and some pointer-to-pointer operations.
2) In this method, 4 bytes are used to identify whether the memory is available, which is a waste.
3) In this method, when the memory is released, there is no memory merging, which will generate a lot of memory fragments.
4) In this method, when the memory is allocated, in the worst case, all the memory blocks need to be traversed, Which is inefficient.
References:
Memory http://www.ibm.com/developerworks/cn/linux/l-memory/