コード例 #1
0
static TA_RetCode freeFileIndexPriv( void *toBeFreed )
{
   TA_PROLOG;
   TA_FileIndexPriv *asciiFileData;
   TA_Libc          *libHandle;
   TA_StringCache   *stringCache;

   asciiFileData = (TA_FileIndexPriv *)toBeFreed;

   libHandle   = asciiFileData->libHandle;
   TA_TRACE_BEGIN( libHandle, freeFileIndexPriv );

   stringCache = TA_GetGlobalStringCache( libHandle );

   if( !asciiFileData )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   if( freeListAndElement( libHandle, asciiFileData->listLocationToken, freeTokenInfo ) != TA_SUCCESS )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   if( freeListAndElement( libHandle, asciiFileData->listCategory, freeCategoryData ) != TA_SUCCESS )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   if( asciiFileData->root )
      TA_FileIndexFreeValueTree( libHandle, asciiFileData->root );

   if( asciiFileData->scratchPad )
      TA_Free( libHandle, asciiFileData->scratchPad );

   if( asciiFileData->wildOneChar )
      TA_StringFree( stringCache, asciiFileData->wildOneChar );

   if( asciiFileData->wildZeroOrMoreChar )
      TA_StringFree( stringCache, asciiFileData->wildZeroOrMoreChar );

   if( asciiFileData->wildOneOrMoreChar )
      TA_StringFree( stringCache, asciiFileData->wildOneOrMoreChar );

   if( asciiFileData->initialCategoryString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryString );

   if( asciiFileData->initialCategoryCountryString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryCountryString );

   if( asciiFileData->initialCategoryExchangeString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryExchangeString );

   if( asciiFileData->initialCategoryTypeString )
      TA_StringFree( stringCache, asciiFileData->initialCategoryTypeString );

   TA_Free( libHandle, asciiFileData );

   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #2
0
ファイル: ta_ACCBANDS.c プロジェクト: trufanov-nok/ta-lib
/* Generated */ TA_LIB_API TA_RetCode TA_ACCBANDS_StateFree( struct TA_ACCBANDS_State** _state )
/* Generated */ 
/* Generated */ #endif
/**** END GENCODE SECTION 9 - DO NOT DELETE THIS LINE ****/
{
   /* insert local variable here */
   TA_RetCode retCode;
   retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.stateSMA1 );
   if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode;
   retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.stateSMA2 );
   if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode;
   retCode = FUNCTION_CALL_STATE_FREE(SMA)( (struct TA_SMA_State**) &STATE_P.stateSMA3 );
   if (retCode != ENUM_VALUE(RetCode,TA_SUCCESS,Success)) return retCode;

/**** START GENCODE SECTION 10 - DO NOT DELETE THIS LINE ****/
/* Generated */ 
/* Generated */ #ifndef TA_FUNC_NO_RANGE_CHECK
/* Generated */ 
/* Generated */    if (_state == NULL)
/* Generated */          return ENUM_VALUE(RetCode,TA_BAD_PARAM,BadParam);
/* Generated */    if (STATE != NULL) {
/* Generated */          if (MEM_P != NULL) TA_Free(MEM_P);
/* Generated */          TA_Free(STATE); STATE = NULL;}
/* Generated */ 
/* Generated */ #endif /* TA_FUNC_NO_RANGE_CHECK */
/* Generated */ 
/**** END GENCODE SECTION 10 - DO NOT DELETE THIS LINE ****/

   /* insert state free code here. */   
   return ENUM_VALUE(RetCode,TA_SUCCESS,Success);
}
コード例 #3
0
ファイル: ta_abstract.c プロジェクト: royratcliffe/ta-lib
TA_RetCode TA_FuncTableFree( TA_StringTable *table )
{
   TA_StringTableFuncHidden *stringTableHidden;
   TA_Libc *libHandle;

   if( table )
   {
      stringTableHidden = (TA_StringTableFuncHidden *)table->hiddenData;
      if( !stringTableHidden )
         return TA_INTERNAL_ERROR(3);
   
      if( stringTableHidden->magicNb != TA_STRING_TABLE_FUNC_MAGIC_NB )
         return TA_BAD_OBJECT;

      libHandle = stringTableHidden->libHandle;

      TA_Free( libHandle, stringTableHidden );

      if( table->string )
         TA_Free( libHandle, (void *)table->string );

      TA_Free( libHandle, table );
   }

   return TA_SUCCESS;
}
コード例 #4
0
TA_RetCode TA_FileSeqClose( TA_FileHandle *handle )
{
   TA_PROLOG
   TA_RetCode retCode;
   TA_FileHandlePriv *fileHandlePriv;
   TA_SystemGlobal *global;
   #if defined( USE_WIN32_API )
   DWORD win32Error;
   BOOL retValue;
   #endif

   TA_TRACE_BEGIN(  TA_FileSeqClose );

   retCode = TA_GetGlobal(  &TA_SystemGlobalControl, (void **)&global );
   if( retCode != TA_SUCCESS )
   {
      TA_TRACE_RETURN( retCode );
   }

   TA_ASSERT( handle != NULL );

   fileHandlePriv = (TA_FileHandlePriv *)handle;

   if( fileHandlePriv )
   {
      #if defined( USE_WIN32_API )
         if( fileHandlePriv->handle != INVALID_HANDLE_VALUE )
         {
            retValue = CloseHandle( fileHandlePriv->handle );
            if( retValue == 0 )
            {
               win32Error = GetLastError();
               global->lastError = win32Error;
               TA_FATAL(  NULL, 0, win32Error );
            }
         }
         if( fileHandlePriv->allocBuffer )
         {
            freeDiskBuffer( fileHandlePriv->allocBuffer,
                            fileHandlePriv->allocBufferSize );
         }
      #endif

      #if defined( USE_OSLAYER )
         if( fileHandlePriv->handle != NULL )
            fclose( fileHandlePriv->handle );
         if( fileHandlePriv->allocBuffer )
            TA_Free(  fileHandlePriv->allocBuffer );
      #endif

      if( fileHandlePriv->streamAccess )
      {
         TA_StreamAccessFree( fileHandlePriv->streamAccess );
      }

      TA_Free(  fileHandlePriv );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #5
0
static TA_RetCode TA_TraceGlobalShutdown( void *globalAllocated )
{
   TA_TraceGlobal *global;
   TA_RetCode retCode = TA_SUCCESS;

   global = (TA_TraceGlobal *)globalAllocated;

   if( !global )
      return retCode;

   if( global->fatalError.str )
      TA_Free(  global->fatalError.str );

   #if !defined( TA_SINGLE_THREAD )      
      retCode = TA_SemaDestroy( &global->fatalSema );
      retCode = TA_SemaDestroy( &global->callSema );
   #endif

   #ifdef TA_DEBUG
      #if defined( TA_SINGLE_THREAD )
         if( global->callStack )
            TA_ListFree( global->callStack );
      #endif

      if( global->functionCalled )
         TA_DictFree( global->functionCalled );
   #endif

   TA_Free(  global );

   return retCode;
}
コード例 #6
0
TA_RetCode TA_PMArrayFree( TA_PMArray *toBeFreed )
{
   TA_PMPriv *pmPriv;
   TA_PM *pm;

   if( toBeFreed )
   {
      pm = (TA_PM *)toBeFreed->hiddenData;
      if( pm )
      {
         pmPriv = (TA_PMPriv *)pm->hiddenData; 
         if( pmPriv )
         {
            if( pmPriv->magicNb != TA_PMPRIV_MAGIC_NB )
               return TA_BAD_OBJECT;

            if( toBeFreed->period != TA_DAILY ) 
            {
               if( toBeFreed->timestamp )
                  TA_Free( (void *)toBeFreed->timestamp );

               if( toBeFreed->data )
                  TA_Free( (void *)toBeFreed->data );
            }
            TA_Free( toBeFreed );
         }
      }
   }

   return TA_SUCCESS;
}
コード例 #7
0
ファイル: ta_abstract.c プロジェクト: BestSean2016/ta-lib
TA_RetCode TA_FuncTableFree( TA_StringTable *table )
{
   TA_StringTablePriv *stringTablePriv;

   if( table )
   {
      stringTablePriv = (TA_StringTablePriv *)table->hiddenData;
      if( !stringTablePriv )
      {
         return TA_INTERNAL_ERROR(3);
      }
   
      if( stringTablePriv->magicNumber != TA_STRING_TABLE_FUNC_MAGIC_NB )
      {
         return TA_BAD_OBJECT;
      }

      if( table->string )
         TA_Free( (void *)table->string );

      TA_Free( table );
   }

   return TA_SUCCESS;
}
コード例 #8
0
TA_RetCode TA_WebPageFree( TA_WebPage *webPage )
{
   TA_WebPageHiddenData *hiddenData;

   if( webPage ) 
   {      
      hiddenData = webPage->hiddenData;
      if( !hiddenData )
         return TA_INTERNAL_ERROR(32);

      if( hiddenData->magicNb != TA_WEBPAGE_MAGIC_NB )
         return TA_BAD_OBJECT;

      /* The object is validated, can start to free ressources
       * from this point.
       */

      /* Free private data */
      TA_Free( hiddenData );

      /* Free public data. */
      if( webPage->content )
         TA_StreamFree( webPage->content );

      TA_Free( webPage );
   }

   return TA_SUCCESS;
}
コード例 #9
0
TA_RetCode TA_FuncTableFree( TA_StringTable *table )
{
   TA_PROLOG
   TA_StringTablePriv *stringTablePriv;

   TA_TRACE_BEGIN( TA_FuncTableFree );

   if( table )
   {
      stringTablePriv = (TA_StringTablePriv *)table->hiddenData;
      if( !stringTablePriv )
      {
         TA_TRACE_RETURN( TA_INTERNAL_ERROR(3) );
      }
   
      if( stringTablePriv->magicNumber != TA_STRING_TABLE_FUNC_MAGIC_NB )
      {
         TA_TRACE_RETURN( TA_BAD_OBJECT );
      }

      if( table->string )
         TA_Free( (void *)table->string );

      TA_Free( table );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #10
0
/**** Local functions definitions.     ****/
static TA_RetCode TA_NetworkGlobalInit( void **globalToAlloc )
{
   #if !defined( TA_SINGLE_THREAD )
   TA_RetCode retCode;
   #endif
   TA_NetworkGlobal *global;

   if( !globalToAlloc )
      return TA_BAD_PARAM;

   *globalToAlloc = NULL;

   #if defined( USE_LIBCURL )
      #if defined(WIN32)
         if( curl_global_init(CURL_GLOBAL_WIN32) != CURLE_OK )
            return TA_LIBCURL_GLOBAL_INIT_FAILED;
      #else
         if( curl_global_init(CURL_GLOBAL_NOTHING) != CURLE_OK )
            return TA_LIBCURL_GLOBAL_INIT_FAILED;
      #endif
   #endif

   global = (TA_NetworkGlobal *)TA_Malloc( sizeof( TA_NetworkGlobal ) );
   if( !global )
      return TA_ALLOC_ERR;

   memset( global, 0, sizeof( TA_NetworkGlobal ) );

   #if defined( USE_LIBCURL )
      global->curlHandle = curl_easy_init();
      if( global->curlHandle == NULL )
      {
         TA_Free(  global );
         return TA_LIBCURL_INIT_FAILED;
      }
   #endif

   #if !defined( TA_SINGLE_THREAD )
      /* Initialize the mutex in a non-block state. */
      retCode = TA_SemaInit( &global->mutexSema, 1 );
      if( retCode != TA_SUCCESS )
      {
         TA_Free(  global );
         return retCode;
      }
   #endif

   global->initialized = 1;

   /* Success, return the allocated memory to the caller. */
   *globalToAlloc = global;
   return TA_SUCCESS;
}
コード例 #11
0
TA_RetCode TA_ReadOpInfoFree( TA_ReadOpInfo *readOpInfoToBeFreed )
{
   if( readOpInfoToBeFreed )
   {
      if( readOpInfoToBeFreed->arrayReadOp )
         TA_Free( readOpInfoToBeFreed->arrayReadOp );

      TA_Free( readOpInfoToBeFreed );
   }

   return TA_SUCCESS;
}
コード例 #12
0
TA_RetCode TA_FileIndexAddTokenInfo( TA_FileIndexPriv *data,
                                     TA_TokenId id,
                                     TA_String *value,
                                     TA_TokenInfo *optBefore )
{
   TA_PROLOG;
   TA_RetCode retCode;
   TA_TokenInfo *info;
   TA_Libc *libHandle;
   TA_StringCache *stringCache;

   libHandle   = data->libHandle;
   TA_TRACE_BEGIN( libHandle, TA_FileIndexAddTokenInfo );

   stringCache = TA_GetGlobalStringCache( libHandle );

   info = TA_Malloc( libHandle, sizeof( TA_TokenInfo ) );

   if( !info )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   info->id = id;
   if( value == NULL )
      info->value = NULL;
   else
   {
      info->value = TA_StringDup( stringCache, value );

      if( !info->value )
      {
         TA_Free( libHandle, info );
         TA_TRACE_RETURN( TA_ALLOC_ERR );
      }
   }

   if( optBefore )
      retCode = TA_ListAddBefore( data->listLocationToken, optBefore, info );
   else
      retCode = TA_ListAddTail( data->listLocationToken, info );

    if( retCode != TA_SUCCESS )
    {
      if( info->value )
         TA_StringFree( stringCache, info->value );
      TA_Free( libHandle, info );
      TA_TRACE_RETURN( retCode );
   }

   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #13
0
size_t libcurlWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
   register int bufferSize;
   TA_WebPage *webPage;
   TA_WebPageHiddenData *webPageHidden;
   TA_RetCode retCode;
   char *buffer;

   webPage = (TA_WebPage *)data;
   webPageHidden = (TA_WebPageHiddenData *)webPage->hiddenData;   

   bufferSize = size * nmemb;
   
   /* Make a copy of the provided data. */
   buffer = TA_Malloc( bufferSize );
   if( !buffer )
      return 0; /* Error. */

   memcpy( buffer, ptr, bufferSize );

   /* Add the data to the stream. */
   if( !webPage->content )
   {
      /* The first buffer will initiate the creation of
       * the stream.
       */
      webPage->content = TA_StreamAllocFromBuffer( buffer, bufferSize,
                                                   NULL, NULL );

      if( !webPage->content )
      {
         TA_Free(  buffer );
         return 0; /* Error. */
      }
   }
   else
   {
      /* Add the buffer to the stream. */
      retCode = TA_StreamAddBuffer( webPage->content, 
                                    buffer, bufferSize,
                                    NULL, NULL );
      if( retCode != TA_SUCCESS )
      {
         TA_Free(  buffer );
         return 0; /* Error */
      }
   }

   return bufferSize;
}
コード例 #14
0
/**** Local functions definitions.     ****/
static void freePrivateHandle( TA_PrivateHandle *privData )
{
   TA_StringCache *stringCache;

   stringCache = TA_GetGlobalStringCache();

   if( stringCache )
   {
      if( privData->ta_sim_ref_cat )
         TA_StringFree( stringCache, privData->ta_sim_ref_cat );

      if( privData->ta_sim_mrg_cat )
         TA_StringFree( stringCache, privData->ta_sim_mrg_cat );

      if( privData->daily_ref_0 )
         TA_StringFree( stringCache, privData->daily_ref_0 );

      if( privData->intra_ref_0 )
         TA_StringFree( stringCache, privData->intra_ref_0 );

      if( privData->mrg_0 )
         TA_StringFree( stringCache, privData->mrg_0 );
   }

   FREE_IF_NOT_NULL( privData->mrgHistory.open );
   FREE_IF_NOT_NULL( privData->mrgHistory.high );
   FREE_IF_NOT_NULL( privData->mrgHistory.low );
   FREE_IF_NOT_NULL( privData->mrgHistory.close );
   FREE_IF_NOT_NULL( privData->mrgHistory.volume );
   FREE_IF_NOT_NULL( privData->mrgHistory.openInterest );
   FREE_IF_NOT_NULL( privData->mrgHistory.timestamp );

   TA_Free(  privData );    
}
コード例 #15
0
TA_RetCode TA_TradeLogFree( TA_TradeLog *toBeFreed )
{
    TA_TradeLogPriv *tradeLogPriv;

    if( toBeFreed )
    {
        /* Make sure this is a valid object. */
        tradeLogPriv = (TA_TradeLogPriv *)toBeFreed->hiddenData;
        if( !tradeLogPriv || (tradeLogPriv->magicNb != TA_TRADELOGPRIV_MAGIC_NB) )
            return TA_BAD_OBJECT;

        /* If it currently belong to a TA_PM, prevent the de-allocation. */
        if( tradeLogPriv->nbReferenceFromTA_PM != 0 )
            return TA_PM_REFERENCE_EXIST;

        /* Free the private members */
        if( tradeLogPriv->tradeDictCAT )
            TA_DictFree(tradeLogPriv->tradeDictCAT);
        if( tradeLogPriv->tradeDictSYM )
            TA_DictFree(tradeLogPriv->tradeDictSYM);
        if( tradeLogPriv->tradeDictCATSYM )
            TA_DictFree(tradeLogPriv->tradeDictCATSYM);
        if( tradeLogPriv->tradeDictUserKey )
            TA_DictFree(tradeLogPriv->tradeDictUserKey);

        TA_AllocatorForDataLog_FreeAll( &tradeLogPriv->allocator );

        /* Free the public portion. */
        TA_Free( toBeFreed );
    }

    return TA_SUCCESS;
}
コード例 #16
0
static TA_RetCode TA_NetworkGlobalShutdown( void *globalAllocated )
{
   TA_NetworkGlobal *global;
   TA_RetCode retCode = TA_SUCCESS;

   global = (TA_NetworkGlobal *)globalAllocated;

   if( !global )
      return retCode;

   if( global->initialized )
   {
      #if defined( USE_WININET )
         if( global->hInternet )
            InternetCloseHandle( global->hInternet);
      #endif

      #if defined( USE_LIBCURL )
         curl_global_cleanup();
      #endif

      global->initialized = 0;
   }

   #if !defined( TA_SINGLE_THREAD )
      retCode = TA_SemaDestroy( &global->mutexSema );
   #endif

   TA_Free( global );

   return retCode;
}
コード例 #17
0
/* Initialize the cache mechanism. */
TA_RetCode TA_StringCacheAlloc( TA_StringCache **newStringCache )
{
   TA_StringCachePriv *stringCachePriv;
   #if !defined( TA_SINGLE_THREAD )
   TA_RetCode retCode;
   #endif

   if( !newStringCache )
      return TA_BAD_PARAM;

   *newStringCache = NULL;

   stringCachePriv = (TA_StringCachePriv *)TA_Malloc( sizeof( TA_StringCachePriv ) );

   if( !stringCachePriv )
      return TA_ALLOC_ERR;

   memset( stringCachePriv, 0, sizeof( TA_StringCachePriv ) );

   #if !defined( TA_SINGLE_THREAD )
   retCode = TA_SemaInit( &stringCachePriv->sema, 1 );
   if( retCode != TA_SUCCESS )
   {
      TA_Free(  stringCachePriv );
      return retCode;
   }
   #endif

   /* Success, return the cache to the caller. */
   *newStringCache = (TA_StringCache *)stringCachePriv;

   return TA_SUCCESS;
}
コード例 #18
0
static TA_RetCode freeSymbolData( TA_Libc *libHandle, void *toBeFreed )
{
   TA_FileIndexSymbolData *symbolData;
   TA_StringCache *stringCache;

   stringCache = TA_GetGlobalStringCache( libHandle );

   symbolData = (TA_FileIndexSymbolData *)toBeFreed;

   if( !symbolData )
      return TA_ALLOC_ERR;

   /* Not yet im[plemented !!!
   if( symbolData->dataPerDate )
   {
      if( freeListAndElement( symbolData->dataPerDate, freeDataPerDate ) != TA_SUCCESS )
         return TA_ALLOC_ERR;
   }
   */

   if( symbolData->string )
      TA_StringFree( stringCache, symbolData->string );

   TA_Free( libHandle, symbolData );

   return TA_SUCCESS;
}
コード例 #19
0
ファイル: ta_readop.c プロジェクト: royratcliffe/ta-lib
TA_RetCode TA_ReadOpInfoFree( TA_ReadOpInfo *readOpInfoToBeFreed )
{
   TA_Libc *libHandle;

   if( readOpInfoToBeFreed )
   {
      libHandle = readOpInfoToBeFreed->libHandle;

      if( readOpInfoToBeFreed->arrayReadOp )
         TA_Free( libHandle, readOpInfoToBeFreed->arrayReadOp );

      TA_Free( libHandle, readOpInfoToBeFreed );
   }

   return TA_SUCCESS;
}
コード例 #20
0
ファイル: ta_webfetch.c プロジェクト: royratcliffe/ta-lib
/* A little utility to fetch a web page and send the raw data
 * to the provided FILE pointer. This ptr could be "stdout" to
 * display on the console.
 *
 * Example:
 *        TA_WebFetch( "www.yahoo.com", stdout );
 *           or
 *        TA_WebFetch( "http://www.yahoo.com/mt", myFile );
 */
TA_RetCode TA_WebFetch( TA_Libc *libHandle, const char *url, FILE *out )
{
   TA_RetCode retCode;
   TA_WebPage *webPage;

   const char *stringStart;
   const char *webSitePage;
   char *allocString;

   unsigned int webSiteLength;

   if( !url )
      return TA_BAD_PARAM;

   allocString = NULL;

   /* Skip the http:// if specified. */
   stringStart = url;
   if( strncmp( url, "http://", 7 ) == 0 )
      stringStart += 7;
   
   /* Find if there is a specifc web page specified. */
   webSitePage = strchr( stringStart, '/' );
   if( webSitePage )
   {
      webSitePage++;
      if( *webSitePage == '\0' )
      {
         webSitePage = NULL;         
      }
      else
      {
         webSiteLength = webSitePage - stringStart - 1;
         allocString = (char *)TA_Malloc( libHandle, webSiteLength+1 );
         if( !allocString )
            return TA_ALLOC_ERR;
         strncpy( allocString, stringStart, webSiteLength );
         allocString[webSiteLength] = '\0';
         stringStart = allocString;
      }
   }

   retCode = TA_WebPageAlloc( libHandle,
                              stringStart,
                              webSitePage,
                              NULL, NULL,
                              &webPage,
                              2 );

   if( allocString )
      TA_Free( libHandle, allocString );

   if( retCode == TA_SUCCESS )
   {
      retCode = TA_StreamToFile( webPage->content, out );
      TA_WebPageFree( webPage );
   }

   return retCode;
}
コード例 #21
0
TA_RetCode TA_StringCacheFree( TA_StringCache *stringCacheToFree )
{
   TA_StringCachePriv *stringCachePriv;
   unsigned int i;

   if( !stringCacheToFree )
      return TA_BAD_PARAM;

   stringCachePriv = (TA_StringCachePriv *)stringCacheToFree;

   for( i=0; i < NB_CACHE_ENTRY; i++ )
   {
      if( stringCachePriv->cache[i] != NULL )
         TA_StringFree( stringCacheToFree,
                        (TA_String *)stringCachePriv->cache[i] );
   }

   #if !defined( TA_SINGLE_THREAD )
      TA_SemaDestroy( &stringCachePriv->sema );
   #endif

   TA_Free(  stringCachePriv );

   return TA_SUCCESS;
}
コード例 #22
0
/**** Local functions definitions.     ****/
static TA_RetCode rangeTestFunction( 
                              TA_Integer startIdx,
                              TA_Integer endIdx,
                              TA_Real *outputBuffer,
                              TA_Integer *outBegIdx,
                              TA_Integer *outNbElement,
                              TA_Integer *lookback,
                              void *opaqueData,
                              unsigned int outputNb )
{
   TA_RetCode retCode;
   TA_RangeTestParam *testParam;
   TA_Real *out1;
   TA_Real *out2;
   TA_Real *dummyOutput;
   (void)outputNb;
  
   testParam = (TA_RangeTestParam *)opaqueData;   

   dummyOutput = TA_Malloc( (endIdx-startIdx+1) * sizeof(TA_Real) );
                     
   if( outputNb == 0 )
   {
      out1 = outputBuffer;
      out2 = dummyOutput;
   }
   else
   {
      out1 = dummyOutput;
      out2 = outputBuffer;
   }

   switch( testParam->test->theFunction )
   {
   case TA_HT_PHASOR_TEST:
      retCode = TA_HT_PHASOR( startIdx,
                              endIdx,
                              testParam->price,
                              outBegIdx,
                              outNbElement,                          
                              out1, out2 );
      *lookback = TA_HT_PHASOR_Lookback();
      break;
   case TA_HT_SINE_TEST:
      retCode = TA_HT_SINE( startIdx,
                            endIdx,
                            testParam->price,
                            outBegIdx,
                            outNbElement,                          
                            out1, out2 );
      *lookback = TA_HT_SINE_Lookback();
      break;
   default:
      retCode = TA_INTERNAL_ERROR(132);
   }

   TA_Free(dummyOutput);
   return retCode;
}
コード例 #23
0
TA_RetCode TA_ParamHolderFree( TA_ParamHolder *paramsToFree )
{
   TA_PROLOG

   TA_ParamHolderPriv     *paramPriv;

   TA_ParamHolderInput    *input;
   TA_ParamHolderOptInput *optInput;
   TA_ParamHolderOutput   *output;

   TA_TRACE_BEGIN( TA_ParamHolderFree );

   if( !paramsToFree )
   {
      TA_TRACE_RETURN( TA_SUCCESS );
   }

   paramPriv = paramsToFree->hiddenData;

   if( !paramPriv )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   if( paramPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   optInput = paramPriv->optIn;
   if( optInput )
      TA_Free( optInput );

   input = paramPriv->in;
   if( input )
      TA_Free( input );

   output = paramPriv->out;
   if( output )
      TA_Free( output );

   TA_Free( paramsToFree );

   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #24
0
ファイル: ta_dict.c プロジェクト: royratcliffe/ta-lib
TA_RetCode TA_DictFree( TA_Dict *dict )
{
   TA_PrivDictInfo *theDict;

   dnode_t   *node;
   dnode_t   *next;
   TA_String *stringToDelete;
   void      *valueToDelete;
   dict_t    *kazlibDict;
   TA_Libc   *libHandle;
   int        flags;

   theDict = (TA_PrivDictInfo *)dict;

   if( theDict == NULL )
      return TA_BAD_PARAM;

   kazlibDict = &theDict->d;
   libHandle  = theDict->libHandle;

   /* Delete all the key-value pair sequentially. */
   node = dict_first( libHandle, kazlibDict );

   while (node != NULL)
   {
      /* Get the next node. */
      next = dict_next( libHandle, kazlibDict, node );

      /* Free the 'node, the 'key' string and the 'value'. */
      flags = theDict->flags;
      valueToDelete  = dnode_get(node);
      if( flags & (TA_DICT_KEY_TWO_STRING|TA_DICT_KEY_ONE_STRING) )
      {
         stringToDelete = TA_StringFromChar(dnode_getkey(node));
         dict_delete_free( libHandle, kazlibDict, node );
         TA_StringFree( TA_GetGlobalStringCache( libHandle ), stringToDelete );
      }
      else
         dict_delete_free( libHandle, kazlibDict, node );

      if( flags & TA_DICT_KEY_TWO_STRING )
      {
         /* The value is a dictionary. Delete it. */
         TA_DictFree( (TA_Dict *)valueToDelete );
      }
      else if( theDict->freeValueFunc )
         theDict->freeValueFunc( libHandle, valueToDelete );

      node = next;
   }

   /* Free the TA_PrivDictInfo */
   TA_Free( libHandle, theDict );

   return TA_SUCCESS;
}
コード例 #25
0
ファイル: ta_abstract.c プロジェクト: royratcliffe/ta-lib
TA_RetCode TA_ParamHoldersFree( TA_ParamHolder *inputParamsToFree,
                                TA_ParamHolder *optInputParamsToFree,
                                TA_ParamHolder *outputParamsToFree )
{
   TA_PROLOG;
   TA_Libc *libHandle;
   TA_ParamHolderPriv *input;
   TA_ParamHolderPriv *optInput;
   TA_ParamHolderPriv *output;

   input    = (TA_ParamHolderPriv *)inputParamsToFree;
   optInput = (TA_ParamHolderPriv *)optInputParamsToFree;
   output   = (TA_ParamHolderPriv *)outputParamsToFree;

   if( !input || !output )
      return TA_BAD_PARAM;

   if( (input->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB) ||
       (output->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB) )
      return TA_INVALID_PARAM_HOLDER;

   libHandle = input->libHandle;
   TA_TRACE_BEGIN( libHandle, TA_ParamHoldersFree );

   if( optInput )
   {
      if( optInput->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
      {
         TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
      }
   }

   TA_Free( libHandle, input );
   if( optInput )
      TA_Free( libHandle, optInput );
   TA_Free( libHandle, output );

   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #26
0
static TA_RetCode TA_SystemGlobalInit( void **globalToAlloc )
{
   TA_PROLOG
   TA_RetCode retCode;
   TA_SystemGlobal *global;

   TA_TRACE_BEGIN( TA_SystemGlobalInit );

   TA_ASSERT( globalToAlloc != NULL );

   *globalToAlloc = NULL;

   global = (TA_SystemGlobal *)TA_Malloc( sizeof( TA_SystemGlobal ) );
   if( !global )
   {
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   memset( global, 0, sizeof( TA_SystemGlobal ) );

   retCode = TA_StringCacheAlloc( &global->dirnameCache );
   if( retCode != TA_SUCCESS )
   {
      TA_Free( global );
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   retCode = TA_StringCacheAlloc( &global->filenameCache );
   if( retCode != TA_SUCCESS )
   {
      TA_StringCacheFree( global->dirnameCache );
      TA_Free( global );
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   /* Success! Return the global to the caller. */
   *globalToAlloc = global;
   TA_TRACE_RETURN( TA_SUCCESS );
}
コード例 #27
0
ファイル: ta_abstract.c プロジェクト: royratcliffe/ta-lib
TA_RetCode TA_GroupTableFree( TA_StringTable *table )
{
   TA_StringTableGroupHidden *stringTableHidden;
   TA_Libc *libHandle;

   if( table )
   {
      stringTableHidden = (TA_StringTableGroupHidden *)table->hiddenData;
      if( !stringTableHidden )
         return TA_INTERNAL_ERROR(1);
   
      if( stringTableHidden->magicNb != TA_STRING_TABLE_GROUP_MAGIC_NB )
         return TA_BAD_OBJECT;

      libHandle = stringTableHidden->libHandle;

      TA_Free( libHandle, stringTableHidden );
      TA_Free( libHandle, table );
   }

   return TA_SUCCESS;
}
コード例 #28
0
TA_RetCode TA_PMFree( TA_PM *toBeFreed )
{
    TA_PMPriv *pmPriv;
    TA_TradeLogPriv *tradeLogPriv;

    if( toBeFreed )
    {
        /* Make sure this is a valid object */
        pmPriv = (TA_PMPriv *)toBeFreed->hiddenData;
        if( !pmPriv || (pmPriv->magicNb != TA_PMPRIV_MAGIC_NB) )
            return TA_BAD_OBJECT;

        /* Clearly mark this object as being unusable. */
        pmPriv->magicNb = 0;

        /* Indicate to all TA_TradeLog that they do
         * no belong to this TA_PM anymore.
         */
        tradeLogPriv = TA_ListAccessHead( &pmPriv->tradeLogList );
        while( tradeLogPriv )
        {
            tradeLogPriv->nbReferenceFromTA_PM--;
            tradeLogPriv = TA_ListAccessNext( &pmPriv->tradeLogList );
        }
        TA_ListFree( &pmPriv->tradeLogList );

        /* Free all the cached arrays. */
        FREE_IF_NOT_NULL( pmPriv->equity );
        FREE_IF_NOT_NULL( pmPriv->arrayTimestamp );

        FREE_IF_NOT_NULL( pmPriv->shortArrayCache.investment );
        FREE_IF_NOT_NULL( pmPriv->shortArrayCache.profit );

        FREE_IF_NOT_NULL( pmPriv->longArrayCache.investment );
        FREE_IF_NOT_NULL( pmPriv->longArrayCache.profit );

        FREE_IF_NOT_NULL( pmPriv->totalArrayCache.investment );
        FREE_IF_NOT_NULL( pmPriv->totalArrayCache.profit );

        /* Last thing that must be freed... */
        TA_Free( toBeFreed );
    }

    return TA_SUCCESS;
}
コード例 #29
0
TA_RetCode TA_DirectoryFree( TA_Directory *directory )
{
   TA_RetCode retCode;
   TA_SystemGlobal *global;

   retCode = TA_GetGlobal(  &TA_SystemGlobalControl, (void **)&global );
   if( retCode != TA_SUCCESS )
      return retCode;

   if( directory )
   {
      stringListFree( global->filenameCache, directory->listOfFile );
      stringListFree( global->dirnameCache, directory->listOfDirectory );
      TA_Free(  directory );
   }

   return TA_SUCCESS;
}
コード例 #30
0
static TA_RetCode freeTokenInfo( TA_Libc *libHandle, void *toBeFreed )
{
   TA_TokenInfo *info;
   TA_StringCache *stringCache;

   stringCache = TA_GetGlobalStringCache( libHandle );

   info = (TA_TokenInfo *)toBeFreed;

   if( !info )
      return TA_ALLOC_ERR;

   if( info->value )
      TA_StringFree( stringCache, info->value );

   TA_Free( libHandle, info );

   return TA_SUCCESS;
}