Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 18:30:21 +0000



Post From: Dynamic Memory

[2023-07-25 00:54:20]
WarriorTrader - Posts: 245
The Allocate Memory function will allocate memory. But if you are allocating memory for a class object and not using new, you have to ensure the constructor is going to get called.




I do not use classes in any of my studies. Like I said it compiles but creates a CPU exception at runtime. The line that I tried is commented out below:

  if (PriceLabelMemory == NULL) {

    PriceLabelMemory = (std::map<int, int> *) new std::map<int, int>;
    //PriceLabelMemory = (std::map<int, int> *) sc.AllocateMemory(sizeof(std::map<int, int>));

  if (PriceLabelMemory != NULL)

    sc.SetPersistentInt(2,(int)PriceLabelMemory); //sc.PersistVars->Integers[2] = (int)PriceLabelMemory;
  else
    return;
  }