Skip to content

Commit

Permalink
[Janitor mode] Fix whitespace
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20443 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
OpenModelica-Hudson committed May 7, 2014
1 parent c6d05d8 commit ff310c7
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions Compiler/runtime/HpcOmBenchmarkExt.cpp
Expand Up @@ -336,52 +336,52 @@ class XmlBenchReader {

std::list<std::list<double> > ReadJsonBenchFileEquations(std::string filePath)
{
std::list<std::list<double> > resultList = std::list<std::list<double> >();

FILE *fp;
long lSize;
char *buffer;
int arraySize, i;
cJSON *root;
cJSON *profileBlocks;

fp = fopen ( filePath.c_str() , "rb" );
if( !fp ) perror(filePath.c_str()),exit(1);

fseek( fp , 0L , SEEK_END);
lSize = ftell( fp );
rewind( fp );

/* allocate memory for entire content */
buffer = (char*)calloc( 1, lSize+1 );
if( !buffer ) fclose(fp),fputs("memory alloc fails",stderr),exit(1);

/* copy the file into the buffer */
if( 1!=fread( buffer , lSize, 1 , fp) )
fclose(fp),free(buffer),fputs("entire read fails",stderr),exit(1);

/* do your work here, buffer is a string contains the whole text */
root = cJSON_Parse(buffer);
profileBlocks = cJSON_GetObjectItem(root,"profileBlocks");
arraySize = cJSON_GetArraySize(profileBlocks);
for(i = 0; i < arraySize; i++)
{
cJSON *item = cJSON_GetArrayItem(profileBlocks, i);
cJSON *idItem = cJSON_GetObjectItem(item, "id");
cJSON *ncallItem = cJSON_GetObjectItem(item, "ncall");
cJSON *timeItem = cJSON_GetObjectItem(item, "time");
std::list<double> tmpLst = std::list<double>();

tmpLst.push_back(idItem->valuedouble);
tmpLst.push_back(timeItem->valuedouble);
tmpLst.push_back(ncallItem->valuedouble);
resultList.push_back(tmpLst);
}

fclose(fp);
free(buffer);

return resultList;
std::list<std::list<double> > resultList = std::list<std::list<double> >();

FILE *fp;
long lSize;
char *buffer;
int arraySize, i;
cJSON *root;
cJSON *profileBlocks;

fp = fopen ( filePath.c_str() , "rb" );
if( !fp ) perror(filePath.c_str()),exit(1);

fseek( fp , 0L , SEEK_END);
lSize = ftell( fp );
rewind( fp );

/* allocate memory for entire content */
buffer = (char*)calloc( 1, lSize+1 );
if( !buffer ) fclose(fp),fputs("memory alloc fails",stderr),exit(1);

/* copy the file into the buffer */
if( 1!=fread( buffer , lSize, 1 , fp) )
fclose(fp),free(buffer),fputs("entire read fails",stderr),exit(1);

/* do your work here, buffer is a string contains the whole text */
root = cJSON_Parse(buffer);
profileBlocks = cJSON_GetObjectItem(root,"profileBlocks");
arraySize = cJSON_GetArraySize(profileBlocks);
for(i = 0; i < arraySize; i++)
{
cJSON *item = cJSON_GetArrayItem(profileBlocks, i);
cJSON *idItem = cJSON_GetObjectItem(item, "id");
cJSON *ncallItem = cJSON_GetObjectItem(item, "ncall");
cJSON *timeItem = cJSON_GetObjectItem(item, "time");
std::list<double> tmpLst = std::list<double>();

tmpLst.push_back(idItem->valuedouble);
tmpLst.push_back(timeItem->valuedouble);
tmpLst.push_back(ncallItem->valuedouble);
resultList.push_back(tmpLst);
}

fclose(fp);
free(buffer);

return resultList;
}

void* HpcOmBenchmarkExtImpl__readCalcTimesFromXml(const char *filename)
Expand Down

0 comments on commit ff310c7

Please sign in to comment.