s*v 发帖数: 3 | 1 I'm looking for the best possible solution to this problem:
My class maintains a dynamic buffer that outside callers can write into.
Callers may write in anything with any size. So my buffer has to grow
dynamically. What's the best way to maintain this buffer so that heap
allocation cost is minimized?
Or: a completely different implementation strategy/thinking recommendation
is
also welcome.
Thanks. |
h****e 发帖数: 2125 | 2 use a linked list, each node has a address pointing to the start of big
chunk of contiguous memory of size N. Whenever it needs to grow, just
allocate another chunk of memory of size N and append a new node having the
starting address to the linked list.
【在 s*v 的大作中提到】 : I'm looking for the best possible solution to this problem: : My class maintains a dynamic buffer that outside callers can write into. : Callers may write in anything with any size. So my buffer has to grow : dynamically. What's the best way to maintain this buffer so that heap : allocation cost is minimized? : Or: a completely different implementation strategy/thinking recommendation : is : also welcome. : Thanks.
|
b******n 发帖数: 592 | 3 but writing anything of any size ...
the
【在 h****e 的大作中提到】 : use a linked list, each node has a address pointing to the start of big : chunk of contiguous memory of size N. Whenever it needs to grow, just : allocate another chunk of memory of size N and append a new node having the : starting address to the linked list.
|
T*****9 发帖数: 2484 | 4 google pintos project 0,please!
【在 s*v 的大作中提到】 : I'm looking for the best possible solution to this problem: : My class maintains a dynamic buffer that outside callers can write into. : Callers may write in anything with any size. So my buffer has to grow : dynamically. What's the best way to maintain this buffer so that heap : allocation cost is minimized? : Or: a completely different implementation strategy/thinking recommendation : is : also welcome. : Thanks.
|