Redian新闻
>
Dynamic buffer management question
avatar
Dynamic buffer management question# Programming - 葵花宝典
s*v
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.
avatar
h*e
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.

avatar
b*n
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.

avatar
T*9
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。