3 ms·
This avoids allocation and is safe (the cost of two extra compares is low because they'll branch the same way all the time, so you'll get branch prediction powe
by bbulkow 16y ago
This avoids allocation and is safe (the cost of two extra compares is low because they'll branch the same way all the time, so you'll get branch prediction power)
char *bufp;
uint8_t buf[1024];
if (need_sz >= 1024)
bufp = malloc(need_sz);
else
bufp = buf;
....
if (bufp != buf) free(bufp);