简体   繁体   中英

How to access memory dynamically without using dynamic allocator include the brk, sbrk and mmap

I have been given a task to simulate heap space and implement malloc , free and realloc on this piece of memory. The size of this piece of memory is not fixed, but I am not allowed to use any standard library allocator, brk , sbrk , mmap , alloca , and variable-length array. Can anybody give me even a piece of hint on this?

Thanks for you guys but static variables are also forbidden.

My interpretation is that you are supposed to write an implementation on a simulated heap. That is, you should write code that allows the user to allocate and deallocate address space. The memory does not physically have to be available, but your code should act as if it manages heap space of some arbitrary size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM