antirez / antirez/sds

malloc/realloc only powers of two?

Abierto
#117 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C
Estrellas
5.6k
Forks
510
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.