Skip to content

Commit 2086486

Browse files
committed
update:depend library
improved:read buffer configure
1 parent e28ca81 commit 2086486

File tree

2 files changed

+10
-37
lines changed

2 files changed

+10
-37
lines changed

XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,12 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVERCONFIG
6161
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_PARAMENT;
6262
return false;
6363
}
64-
int nCount = 0;
65-
XCHAR tszMsgBuffer[4096];
66-
while (1)
67-
{
68-
int nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File);
69-
if (nRet <= 0)
70-
{
71-
break;
72-
}
73-
nCount += nRet;
74-
}
64+
XCHAR tszMsgBuffer[8192] = {};
65+
size_t nRet = fread(tszMsgBuffer, 1, sizeof(tszMsgBuffer), pSt_File);
7566
fclose(pSt_File);
7667

7768
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_JsonBuilder.newCharReader());
78-
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError))
69+
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nRet, &st_JsonRoot, &st_JsonError))
7970
{
8071
Config_IsErrorOccur = true;
8172
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_PARSE;
@@ -282,21 +273,12 @@ bool CConfig_Json::Config_Json_Version(LPCXSTR lpszConfigFile, XENGINE_SERVERCON
282273
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_PARAMENT;
283274
return false;
284275
}
285-
int nCount = 0;
286-
XCHAR tszMsgBuffer[4096];
287-
while (1)
288-
{
289-
int nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File);
290-
if (nRet <= 0)
291-
{
292-
break;
293-
}
294-
nCount += nRet;
295-
}
276+
XCHAR tszMsgBuffer[8192] = {};
277+
size_t nRet = fread(tszMsgBuffer, 1, sizeof(tszMsgBuffer), pSt_File);
296278
fclose(pSt_File);
297279

298280
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_JsonBuilder.newCharReader());
299-
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError))
281+
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nRet, &st_JsonRoot, &st_JsonError))
300282
{
301283
Config_IsErrorOccur = true;
302284
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_PARSE;
@@ -356,21 +338,12 @@ bool CConfig_Json::Config_Json_LoadBalance(LPCXSTR lpszConfigFile, XENGINE_LBCON
356338
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_PARAMENT;
357339
return false;
358340
}
359-
int nCount = 0;
360-
XCHAR tszMsgBuffer[4096];
361-
while (1)
362-
{
363-
int nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File);
364-
if (nRet <= 0)
365-
{
366-
break;
367-
}
368-
nCount += nRet;
369-
}
341+
XCHAR tszMsgBuffer[8192] = {};
342+
size_t nRet = fread(tszMsgBuffer, 1, sizeof(tszMsgBuffer), pSt_File);
370343
fclose(pSt_File);
371344

372345
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_JsonBuilder.newCharReader());
373-
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError))
346+
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nRet, &st_JsonRoot, &st_JsonError))
374347
{
375348
Config_IsErrorOccur = true;
376349
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_PARSE;

XEngine_Source/XEngine_Depend

Submodule XEngine_Depend updated 41 files

0 commit comments

Comments
 (0)