antirez / antirez/sds

malloc/realloc only powers of two?

オープン
#117 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C
スター
5.6k
フォーク
510
PR マージ指標
30日以内にマージされた PR はありません

説明

It might be worth considering only allocating strings of a capacity that is a power of two (including header) to reduce memory fragmentations:

A simple code snippet to round up to the next power of two:

```
unsigned int v; // compute the next highest power of 2 of 32-bit v

--v;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
++v;
```

I can make the code contribution if you'd like.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。