Browse Source

reformatting: pow2gt

Max Bruckner 8 năm trước cách đây
mục cha
commit
d5bd497636
1 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 13 1
      cJSON.c

+ 13 - 1
cJSON.c

@@ -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;