浏览代码

print_value: Use sizeof(literal) instead of magic numbers

Max Bruckner 7 年之前
父节点
当前提交
f07a3b7cb3
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      cJSON.c

+ 3 - 3
cJSON.c

@@ -1277,7 +1277,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp
     switch ((item->type) & 0xFF)
     {
         case cJSON_NULL:
-            output = ensure(output_buffer, 5);
+            output = ensure(output_buffer, sizeof("null"));
             if (output == NULL)
             {
                 return false;
@@ -1286,7 +1286,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp
             return true;
 
         case cJSON_False:
-            output = ensure(output_buffer, 6);
+            output = ensure(output_buffer, sizeof("false"));
             if (output == NULL)
             {
                 return false;
@@ -1295,7 +1295,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp
             return true;
 
         case cJSON_True:
-            output = ensure(output_buffer, 5);
+            output = ensure(output_buffer, sizeof("true"));
             if (output == NULL)
             {
                 return false;