Changeset 36:dc19311c025a in rrlib_xml


Ignore:
Timestamp:
16.10.2011 15:29:25 (8 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Deleted generated copy constructor in tXMLDocument, because it is unsafe. Added move-constructor instead.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tXMLDocument.cpp

    r34 r36  
    9797} 
    9898 
     99tXMLDocument::tXMLDocument(tXMLDocument && other) 
     100    : document(0), 
     101    root_node(0) 
     102{ 
     103  std::swap(document, other.document); 
     104  std::swap(root_node, other.root_node); 
     105} 
     106 
    99107//---------------------------------------------------------------------- 
    100108// tXMLDocument destructor 
     
    102110tXMLDocument::~tXMLDocument() 
    103111{ 
    104   xmlFreeDoc(this->document); 
     112  if (this->document) 
     113  { 
     114    xmlFreeDoc(this->document); 
     115  } 
    105116} 
    106117 
  • tXMLDocument.h

    r34 r36  
    125125  tXMLDocument(const void *buffer, size_t size, bool validate = true); 
    126126 
     127  /*! 
     128   * move constructor 
     129   */ 
     130  tXMLDocument(tXMLDocument && other); 
     131 
    127132  /*! The dtor of tXMLDocument 
    128133   */ 
     
    179184  mutable tXMLNode *root_node; 
    180185 
     186  tXMLDocument(const tXMLDocument&); // generated copy-constructor is not safe 
    181187}; 
    182188 
Note: See TracChangeset for help on using the changeset viewer.