ItemAttributes::~ItemAttributes() { if (m_firstAttr) { deleteAttrs(m_firstAttr); } }
void ItemAttributes::deleteAttrs(Attribute* attr) { if (attr) { if (validateStrAttrType(attr->type)) { delete (std::string*)attr->value; } Attribute* next_attr = attr->next; attr->next = NULL; if (next_attr) { deleteAttrs(next_attr); } delete attr; } }
void ItemAttributes::deleteAttrs(Attribute* attr) { //deletes all attributes recursively if(attr){ //if is string type, delete the allocated string if(validateStrAttrType(attr->type)){ delete (std::string*)attr->value; } Attribute* next_attr = attr->next; attr->next = NULL; //delete next while it was not NULL if(next_attr){ deleteAttrs(next_attr); } delete attr; } }