From 547de2d48cb9534efcc090e6875faa6d34bfb392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E4=BC=A0=E5=AE=9D?= Date: Thu, 12 Mar 2020 21:51:38 +0800 Subject: [PATCH] fix name of var --- inc/cson.h | 2 +- src/cson.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/cson.h b/inc/cson.h index 85e04ce..e7b719c 100644 --- a/inc/cson.h +++ b/inc/cson.h @@ -95,7 +95,7 @@ typedef struct reflect_item_t { size_t size; /**< size of property */ cson_type type; /**< corresponding json type */ const struct reflect_item_t* reflect_tbl; /**< must be specified when type is object or array */ - size_t arraySize; /**< size of per array item. must be specified when type is array */ + size_t arrayItemSize; /**< size of per array item. must be specified when type is array */ char* arrayCountField; /**< field saving array size */ int nullable; /**< paser return failure when the field is not found and nullable equals to 0 */ } reflect_item_t; diff --git a/src/cson.c b/src/cson.c index 70bbf93..63de238 100644 --- a/src/cson.c +++ b/src/cson.c @@ -263,10 +263,10 @@ int getJsonArray(void* input, const reflect_item_t* tbl, int index, cson_t* obj) cson_t jotmp; if (tbl[index].reflect_tbl[0].field[0] == '0') { /* field start with '0' mean basic types. */ - ret = jsonPackTbl[tbl[index].reflect_tbl[0].type](pSrc + (i * tbl[index].arraySize), tbl[index].reflect_tbl, 0, &jotmp); + ret = jsonPackTbl[tbl[index].reflect_tbl[0].type](pSrc + (i * tbl[index].arrayItemSize), tbl[index].reflect_tbl, 0, &jotmp); } else { jotmp = cson_object(); - ret = csonStruct2JsonObj(jotmp, pSrc + (i * tbl[index].arraySize), tbl[index].reflect_tbl); + ret = csonStruct2JsonObj(jotmp, pSrc + (i * tbl[index].arrayItemSize), tbl[index].reflect_tbl); } if (ret == ERR_NONE) { @@ -432,7 +432,7 @@ int parseJsonArray(cson_t jo_tmp, void* output, const reflect_item_t* tbl, int i return ERR_MISSING_FIELD; } - char* pMem = (char*)malloc(arraySize * tbl[index].arraySize); + char* pMem = (char*)malloc(arraySize * tbl[index].arrayItemSize); if (pMem == NULL) return ERR_MEMORY; long long successCount = 0; @@ -442,9 +442,9 @@ int parseJsonArray(cson_t jo_tmp, void* output, const reflect_item_t* tbl, int i int ret; if (tbl[index].reflect_tbl[0].field[0] == '0') { /* field start with '0' mean basic types. */ - ret = jsonObjProcTbl[tbl[index].reflect_tbl[0].type](item, pMem + (successCount * tbl[index].arraySize), tbl[index].reflect_tbl, 0); + ret = jsonObjProcTbl[tbl[index].reflect_tbl[0].type](item, pMem + (successCount * tbl[index].arrayItemSize), tbl[index].reflect_tbl, 0); } else { - ret = csonJsonObj2Struct(item, pMem + (successCount * tbl[index].arraySize), tbl[index].reflect_tbl); + ret = csonJsonObj2Struct(item, pMem + (successCount * tbl[index].arrayItemSize), tbl[index].reflect_tbl); } if (ret == ERR_NONE) { @@ -717,7 +717,7 @@ void csonLoopProperty(void* pData, const reflect_item_t* tbl, loop_func_t func) long long size = getIntegerValueFromPointer(ptr, tbl[countIndex].size); for (long long j = 0; j < size; j++) { - csonLoopProperty(*((char**)pProperty) + j * tbl[i].arraySize, tbl[i].reflect_tbl, func); + csonLoopProperty(*((char**)pProperty) + j * tbl[i].arrayItemSize, tbl[i].reflect_tbl, func); } } else if (tbl[i].type == CSON_OBJECT) { csonLoopProperty(pProperty, tbl[i].reflect_tbl, func);