Login Page - Create Account

Support Board


Date/Time: Fri, 20 Sep 2024 00:04:25 +0000



Post From: Persistant SCString

[2014-08-21 07:31:52]
Sierra Chart Engineering - Posts: 104368
Yes, this is correct:
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28DELETE_CPP%29;k%28DELETE%29&rd=true

Here is another example which uses the internal allocation and free functions.


SCSFExport scsf_DynamicMemoryAllocationExample(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "Dynamic Memory Allocation Example";

    sc.AutoLoop = 1;

    // This should be set to 0 when using new and delete in a study function.
    sc.FreeDLL = 0;

    return;
  }


  // Do data processing
  double * p_DoubleArray = (double*)sc.PersistVars->i1;

  if(sc.LastCallToFunction)
  {
    if(p_DoubleArray != NULL)
    {
      sc.FreeMemory( p_DoubleArray);
      sc.PersistVars->i1 = NULL;
    }

    return;
  }

  if(p_DoubleArray == NULL)
  {
    //Allocate an array of 1024 doubles.
    p_DoubleArray = (double *) sc.AllocateMemory( 1024 * sizeof(double) );

    if(p_DoubleArray != NULL)
      sc.PersistVars->i1 = (int)p_DoubleArray;
    else
      return;
  }

  //assign value to one of the elements
  p_DoubleArray[0] = 100;

  return;


}


Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2014-08-21 07:32:07