1
0
mirror of https://github.com/DaveGamble/cJSON synced 2024-12-25 16:12:04 +00:00

reformatting: pow2gt

This commit is contained in:
Max Bruckner 2016-09-27 23:44:47 +07:00
parent 88cbe57ba4
commit d5bd497636

14
cJSON.c
View File

@ -199,7 +199,19 @@ static const char *parse_number(cJSON *item, const char *num)
return num;
}
static int pow2gt (int x) { --x; x|=x>>1; x|=x>>2; x|=x>>4; x|=x>>8; x|=x>>16; return x+1; }
/* calculate the next largest power of 2 */
static int pow2gt (int x)
{
--x;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return x + 1;
}
typedef struct {char *buffer; int length; int offset; } printbuffer;