From c0fe37ab8ea7c0e9a12113ab33a9d710be3f6b9c Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 23 Feb 2016 19:41:49 +0100 Subject: [PATCH 1/2] Fixed: Memory leak --HG-- branch : develop --- code/ryzom/client/src/cdb_synchronised.cpp | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index d5239ce0d..40aa11316 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -132,18 +132,26 @@ void CCDBSynchronised::read( const string &fileName ) // value token = strtok(buffer," \t"); - if( token == NULL ) continue; - sint64 value; - fromString((const char*)token, value); - // property name - token = strtok(NULL," \n"); - if( token == NULL ) continue; - string propName(token); + if (token) + { + sint64 value; + fromString((const char*)token, value); - // set the value of the property - ICDBNode::CTextId txtId(propName); - _Database->setProp(txtId,value); + // property name + token = strtok(NULL," \n"); + + if (token) + { + string propName(token); + + // set the value of the property + ICDBNode::CTextId txtId(propName); + _Database->setProp(txtId, value); + } + } + + delete [] buffer; } f.close(); @@ -177,7 +185,6 @@ void CCDBSynchronised::write( const string &fileName ) { nlwarning(" can't write %s : the database has not been initialized",fileName.c_str()); } - } // write // From 2b64e30aa2f664aa2b4f153b930c03cec3c0ba9c Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 23 Feb 2016 19:42:15 +0100 Subject: [PATCH 2/2] Changed: Minor changes --HG-- branch : develop --- code/ryzom/client/src/cdb_synchronised.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 40aa11316..3d102071b 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -155,7 +155,6 @@ void CCDBSynchronised::read( const string &fileName ) } f.close(); - } // read // @@ -168,7 +167,7 @@ void CCDBSynchronised::write( const string &fileName ) { bool res = false; - if( _Database != 0 ) + if (_Database != 0) { FILE * f = nlfopen(fileName, "w"); if (f) @@ -292,11 +291,9 @@ string CCDBSynchronised::getString( uint32 id ) { return (*itStr).second; } - else - { - nlwarning(" string with id %d was not found",id); - return ""; - } + + nlwarning(" string with id %d was not found",id); + return ""; } // getString //