Changeset 97906d8


Ignore:
Timestamp:
Mar 20, 2017 6:09:06 PM (6 months ago)
Author:
www-data <www-data@…>
Branches:
master, feature_CIS, release_9.4, release_9.5
Children:
3e44184
Parents:
f565b5c
git-author:
Brennan Bell <b.bell@…> (03/17/17 14:11:51)
git-committer:
www-data <www-data@…> (03/20/17 18:09:06)
Message:

ticket:1511 - small reduction to memory leaks arising with debug params enabled

Summary:
r_Minterval and r_Point ::get_string_representation() allocates memory

for a reason, but some places in the code thought it was simply a
char* output.

Test Plan:
run valgrind with a full leak check and debug parameters enabled

with your favourite query (I used concat with some nullValues),
and you should no longer see a memory leak.

Reviewers: dmisev

Reviewed By: dmisev

Differential Revision: http://codereview.rasdaman.org/D359

Files:
15 edited

Legend:

Unmodified
Added
Removed
  • applications/rasgeo/rasimport.cc

    r1b40e87 r97906d8  
    688688
    689689        LDEBUG << "src img size:     " << srcGeoRegion.ncols << " x " << srcGeoRegion.nrows;
    690         LDEBUG << "readGDALImgDOM:   " << readGDALImgDOM.get_string_representation();
     690        LDEBUG << "readGDALImgDOM:   " << readGDALImgDOM.to_string();
    691691
    692692        // shift the insertGeoRegion by the user specified shiftVector; account for (geo) spatial
     
    749749            }
    750750
    751             LDEBUG << "current img sdom: " << aint.get_string_representation();
     751            LDEBUG << "current img sdom: " << aint.to_string();
    752752
    753753            // ================================== 3D UPDATE ======================================
     
    935935        }
    936936
    937         LDEBUG << "writeShift: " << writeShift.get_string_representation();
     937        LDEBUG << "writeShift: " << writeShift.to_string();
    938938
    939939        // determine the new image region (valid after the src has been written into
     
    21962196        }
    21972197
    2198         LDEBUG << "user pixel shift: " << shiftPt.get_string_representation();
     2198        LDEBUG << "user pixel shift: " << shiftPt.to_string();
    21992199
    22002200
  • catalogmgr/nullvalues.cc

    r1b40e87 r97906d8  
    5454    if (nullValues != NULL)
    5555    {
    56         LDEBUG << "returning null values " << nullValues->get_string_representation();
     56        LDEBUG << "returning null values " << nullValues->to_string();
    5757    }
    5858    return nullValues;
     
    6464    if (newNullValues != NULL)
    6565    {
    66         LDEBUG << "setting to " << newNullValues->get_string_representation();
     66        LDEBUG << "setting to " << newNullValues->to_string();
    6767    }
    6868    nullValues = newNullValues;
  • mddmgr/mddcoll.cc

    r1b40e87 r97906d8  
    527527            {
    528528                result.append(" NULL VALUES ");
    529                 result.append(nullValues->get_string_representation());
     529                result.append(nullValues->to_string());
    530530            }
    531531
  • qlparser/qtmarrayop.cc

    r1b40e87 r97906d8  
    225225
    226226        // create a new QtMDD object as carrier object for the transient MDD object
    227         returnValue = new QtMDD(static_cast<MDDObj*>(mddres));
     227        returnValue = new QtMDD(mddres);
    228228
    229229        // delete old operands
  • rasdl/parse.cc

    r1b40e87 r97906d8  
    988988    {
    989989        fprintf(stream, ", ");
    990         fprintf(stream, "%s", nullValues->get_string_representation());
     990        fprintf(stream, "%s", nullValues->to_string().c_str());
    991991    }
    992992    fprintf(stream, " >");
     
    10421042    if (nullValues != NULL)
    10431043    {
    1044         LDEBUG << "Set null values to " << nullValues->get_string_representation();
     1044        LDEBUG << "Set null values to " << nullValues->to_string();
    10451045        setType->setNullValues(*nullValues);
    10461046    }
  • rasdl/rasdl.cc

    r1b40e87 r97906d8  
    291291        if (nullValues)
    292292        {
    293             cout << " null values " << nullValues->get_string_representation();
     293            cout << " null values " << nullValues->to_string();
    294294        }
    295295
  • raslib/minterval.cc

    rc9d1b3f r97906d8  
    906906}
    907907
     908std::string
     909r_Minterval::to_string() const
     910{
     911    char* stringRep = this->get_string_representation();
     912    std::string returnValue(stringRep);
     913    std::free(stringRep);
     914    return returnValue;
     915}
     916
    908917std::string
    909918r_Minterval::get_named_axis_string_representation() const
  • raslib/minterval.hh

    r1b40e87 r97906d8  
    525525    /**
    526526      The string representation delivered by this method is allocated using {\tt malloc()} and
    527       has to be free unsing {\tt free()} in the end. It can be used to construct a {\tt r_Minterval}
     527      has to be free using {\tt free()} in the end. It can be used to construct a {\tt r_Minterval}
    528528      again with a special constructor provided. The string representation is build using
    529529      {\tt print_status()}.
    530530    */
     531   
     532    /**
     533     * If you want the output of {\tt get_string_representation()},
     534     * but you do not want to worry about memory allocation/deallocation.
     535     */
     536    std::string to_string() const;
    531537
    532538    /**
  • raslib/point.cc

    r1b40e87 r97906d8  
    375375}
    376376
     377std::string
     378r_Point::to_string() const
     379{
     380    char* stringRep = this->get_string_representation();
     381    std::string returnValue(stringRep);
     382    std::free(stringRep);
     383    return returnValue;
     384}
     385
    377386std::ostream& operator<<(std::ostream& s, const r_Point& d)
    378387{
  • raslib/point.hh

    r1b40e87 r97906d8  
    139139    /**
    140140      The string representation delivered by this method is allocated using {\tt malloc()} and
    141       has to be free unsing {\tt free()} in the end. It can be used to construct a {\tt r_Point}
     141      has to be free using {\tt free()} in the end. It can be used to construct a {\tt r_Point}
    142142      again with a special constructor provided. The string representation is build using
    143143      {\tt print_status()}.
    144144    */
     145   
     146    /**
     147     * If you want the output of {\tt get_string_representation()},
     148     * but you do not want to worry about memory allocation/deallocation.
     149     */
     150    std::string to_string() const;
    145151
    146152private:
  • rasnetprotocol/rasnetclientcomm.cc

    r91ca341 r97906d8  
    887887    startInsertMDDReq.set_client_id(this->clientId);
    888888    startInsertMDDReq.set_collname(collName);
    889     startInsertMDDReq.set_domain(mar->spatial_domain().get_string_representation());
     889    startInsertMDDReq.set_domain(mar->spatial_domain().to_string());
    890890    startInsertMDDReq.set_type_length(mar->get_type_length());
    891891    startInsertMDDReq.set_type_name(mar->get_type_name());
     
    15291529
    15301530    startInsertTransMDDReq.set_client_id(this->clientId);
    1531     startInsertTransMDDReq.set_domain(mdd->spatial_domain().get_string_representation());
     1531    startInsertTransMDDReq.set_domain(mdd->spatial_domain().to_string());
    15321532    startInsertTransMDDReq.set_type_length(mdd->get_type_length());
    15331533    startInsertTransMDDReq.set_type_name(mdd->get_type_name());
  • rasnetprotocol/rasnetservercomm.cc

    r91ca341 r97906d8  
    741741
    742742        response->set_status(statusCode);
    743         response->set_domain(mddDomain.get_string_representation());
     743        response->set_domain(mddDomain.to_string());
    744744        response->set_type_name(typeName);
    745745        response->set_type_structure(typeStructure);
  • relcatalogif/collectiontype.C

    rc867322 r97906d8  
    106106{
    107107  if (nullValues != NULL) {
    108     LDEBUG << "returning null values: " << nullValues->get_string_representation();
     108    LDEBUG << "returning null values: " << nullValues->to_string();
    109109  }
    110110  return nullValues;
  • rnprotocol/rnpclientcomm2.cc

    r1b40e87 r97906d8  
    661661    startRequest(RnpRasserver::cmd_startinsTmdd);
    662662    encoder.addInt32Parameter(RnpRasserver::pmt_clientid,   clientID);
    663     encoder.addStringParameter(RnpRasserver::pmt_domain,     mdd->spatial_domain().get_string_representation());
     663    encoder.addStringParameter(RnpRasserver::pmt_domain, mdd->spatial_domain().to_string().c_str());
    664664    encoder.addInt32Parameter(RnpRasserver::pmt_typelength, static_cast<int>(mdd->get_type_length()));
    665665    encoder.addStringParameter(RnpRasserver::pmt_typename,   mdd->get_type_name());
  • rnprotocol/rnpservercomm.cc

    r1b40e87 r97906d8  
    623623    encoder.addInt32Parameter(RnpRasserver::pmt_returnstatus, status);
    624624    LDEBUG << "adding return status " << status;
    625     encoder.addStringParameter(RnpRasserver::pmt_oidstring,     mddDomain.get_string_representation());
    626     encoder.addStringParameter(RnpRasserver::pmt_typename,      typeName);
     625    encoder.addStringParameter(RnpRasserver::pmt_oidstring, mddDomain.to_string().c_str());
     626    encoder.addStringParameter(RnpRasserver::pmt_typename, typeName);
    627627    encoder.addStringParameter(RnpRasserver::pmt_typestructure, typeStructure);
    628628    encoder.addStringParameter(RnpRasserver::pmt_oidstring, oid.get_string_representation() ? oid.get_string_representation() : "");
     
    11751175        const char* domain = result[i].get_string_representation();
    11761176        encoder.addStringParameter(RnpRasserver::pmt_domain, domain);
    1177 
     1177        // r_Minterval::get_string_representation() allocates memory, so it must be freed after being copied.
    11781178        free(static_cast<void*>(const_cast<char*>(domain)));
    11791179    }
Note: See TracChangeset for help on using the changeset viewer.