浏览代码

Add const qualifier to cJSON_CreateStringArray

Adds a const qualifier to the strings in the array to avoid discarding
it from arguments.
Bernt Johan Damslora 5 年之前
父节点
当前提交
26772a8ef7
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      cJSON.c
  2. 1 1
      cJSON.h

+ 1 - 1
cJSON.c

@@ -2524,7 +2524,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
     return a;
     return a;
 }
 }
 
 
-CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
+CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
 {
 {
     size_t i = 0;
     size_t i = 0;
     cJSON *n = NULL;
     cJSON *n = NULL;

+ 1 - 1
cJSON.h

@@ -213,7 +213,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
 CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
 CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
-CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
+CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
 
 
 /* Append item to the specified array/object. */
 /* Append item to the specified array/object. */
 CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
 CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);