From: Anida Khizar Date: Wed, 1 Feb 2023 14:20:07 +0000 (+0100) Subject: [Partial load] shared_ptr instead of raw pointer X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6389ef0c5fd351db6495f79df167ec00cabe9cb9;p=tools%2Fmedcoupling.git [Partial load] shared_ptr instead of raw pointer --- diff --git a/src/MEDLoader/MEDFilterEntity.hxx b/src/MEDLoader/MEDFilterEntity.hxx index 4a61d6ee6..d806a2260 100644 --- a/src/MEDLoader/MEDFilterEntity.hxx +++ b/src/MEDLoader/MEDFilterEntity.hxx @@ -16,29 +16,29 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anida Khizar (CEA/DES) #ifndef __MEDFILTERENTITY_HXX__ #define __MEDFILTERENTITY_HXX__ #include "MEDCouplingPartDefinition.hxx" #include "med.h" +#include namespace MEDCoupling { class MEDFilterEntity { public: - MEDFilterEntity() { _filter = new med_filter; } - ~MEDFilterEntity() { delete _filter; } + MEDFilterEntity() { _filter = std::make_shared(); } void init() { *_filter = MED_FILTER_INIT; } inline void fill(med_idt fid, mcIdType nbOfEntity, mcIdType nbOfValuesPerEntity, mcIdType nbOfConstituentPerValue, const med_int constituentSelect, const med_switch_mode switchMode, const med_storage_mode storageMode, const char * const profileName, const PartDefinition* pd); - const med_filter *getPtr() const { return _filter; } - void close() { MEDfilterClose(_filter); } + const med_filter *getPtr() const { return _filter.get(); } + void close() { MEDfilterClose(_filter.get()); } private: - med_filter *_filter; + std::shared_ptr _filter; }; } @@ -61,7 +61,7 @@ void MEDCoupling::MEDFilterEntity::fill(med_idt fid, mcIdType nbOfEntity, mcIdTy MEDfilterBlockOfEntityCr(fid,ToMedInt(nbOfEntity),ToMedInt(nbOfValuesPerEntity),ToMedInt(nbOfConstituentPerValue), constituentSelect,switchMode,storageMode,profileName, /*start*/ToMedInt(strt+1),/*stride*/ToMedInt(step),/*count*/1,/*blocksize*/ToMedInt(nbOfEltsToLoad), - /*lastblocksize=useless because count=1*/0,_filter); + /*lastblocksize=useless because count=1*/0,_filter.get()); return; } const DataArrayPartDefinition *dpd(dynamic_cast(pd)); @@ -79,7 +79,7 @@ void MEDCoupling::MEDFilterEntity::fill(med_idt fid, mcIdType nbOfEntity, mcIdTy MEDfilterEntityCr(fid,ToMedInt(nbOfEntity),ToMedInt(nbOfValuesPerEntity),ToMedInt(nbOfConstituentPerValue), constituentSelect,switchMode,storageMode,profileName, ToMedInt(nbOfEltsToLoad), dpdPlus1.data(), - _filter); + _filter.get()); return; } throw INTERP_KERNEL::Exception("MEDFilterEntity::fill : empty part definition !");