Ignore:
Timestamp:
05/23/19 22:45:38 (6 years ago)
Author:
Maciej Komosinski
Message:

Fixed freeing memory during mutation and crossing over

File:
1 edited

Legend:

Unmodified
Added
Removed
  • js/sdk/js_interface/js_types.h

    r865 r879  
    172172                int _met = 0;
    173173
    174                 if (lastMutate == nullptr) delete[] lastMutate;
     174                if (lastMutate != nullptr) free(lastMutate);
    175175                lastMutate = strdup(geno);
    176176                return genoOper->mutate(lastMutate, _ch, _met);
     
    187187                float _ch2 = 0;
    188188
    189                 if (lastCross1 == nullptr) delete[] lastCross1;
     189                if (lastCross1 != nullptr) free(lastCross1);
    190190                lastCross1 = strdup(geno1);
    191191
    192                 if (lastCross2 == nullptr) delete[] lastCross2;
     192                if (lastCross2 != nullptr) free(lastCross2);
    193193                lastCross2 = strdup(geno2);
    194194                return genoOper->crossOver(lastCross1, lastCross2, _ch1, _ch2);
     
    207207        ~GenoOperatorsHelper()
    208208        {
    209                 if (lastMutate == nullptr) delete[] lastMutate;
    210                 if (lastCross1 == nullptr) delete[] lastCross1;
    211                 if (lastCross2 == nullptr) delete[] lastCross2;
     209                if (lastMutate != nullptr) free(lastMutate);
     210                if (lastCross1 != nullptr) free(lastCross1);
     211                if (lastCross2 != nullptr) free(lastCross2);
    212212                //delete genoOper;
    213213        }
Note: See TracChangeset for help on using the changeset viewer.