当前位置: 首页>>代码示例>>C++>>正文


C++ TA_Malloc函数代码示例

本文整理汇总了C++中TA_Malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ TA_Malloc函数的具体用法?C++ TA_Malloc怎么用?C++ TA_Malloc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TA_Malloc函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: void

/**** Global functions definitions.   ****/
TA_Dict *TA_DictAlloc( TA_Libc *libHandle,
                       unsigned int flags,                       
                       void (*freeValueFunc)( TA_Libc *libHandle, void *) )
{
   TA_PrivDictInfo *theDict;

   if( !libHandle )
      return NULL;

   /* Alloc the structure used as an handle for this dictionary. */
   theDict = (TA_PrivDictInfo *) TA_Malloc( libHandle, sizeof( TA_PrivDictInfo ) );

   if( !theDict )
      return NULL;

   theDict->flags = flags;

   /* Create the Kazlib dictionary. */
   if( flags & TA_DICT_KEY_ONE_STRING )
      dict_init( libHandle, &theDict->d, DICTCOUNT_T_MAX, compareFunction_S );
   else if( flags & TA_DICT_KEY_TWO_STRING )
      dict_init( libHandle, &theDict->d, DICTCOUNT_T_MAX, compareFunction_S );
   else if( flags & TA_DICT_KEY_INTEGER )
      dict_init( libHandle, &theDict->d, DICTCOUNT_T_MAX, compareFunction_I );

   /* Keep a copy of the freeValueFunc pointer for later use. */
   theDict->freeValueFunc = freeValueFunc;

   /* Remember to which memory context we belong. */
   theDict->libHandle = libHandle;

   return (TA_Dict *)theDict;
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:34,代码来源:ta_dict.c

示例2: TA_WebFetch

/* 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;
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:69,代码来源:ta_webfetch.c

示例3: TA_GroupTableAlloc

/**** Global functions definitions.   ****/
TA_RetCode TA_GroupTableAlloc( TA_StringTable **table )
{
   TA_StringTable *stringTable;
   TA_StringTablePriv *stringTablePriv;

   if( table == NULL )
   {
      return TA_BAD_PARAM;
   }

   stringTable = (TA_StringTable *)TA_Malloc( sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   if( !stringTable )
   {
      *table = NULL;
      return TA_ALLOC_ERR;
   }

   memset( stringTable, 0, sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   stringTablePriv = (TA_StringTablePriv *)(((char *)stringTable)+sizeof(TA_StringTable));
   stringTablePriv->magicNumber = TA_STRING_TABLE_GROUP_MAGIC_NB;

   stringTable->size = TA_NB_GROUP_ID;
   stringTable->string = &TA_GroupString[0];
   stringTable->hiddenData = stringTablePriv;

   /* From this point, TA_FuncTableFree can be safely called. */

   /* Success. Return the table to the caller. */
   *table = stringTable;

   return TA_SUCCESS;
}
开发者ID:BestSean2016,项目名称:ta-lib,代码行数:33,代码来源:ta_abstract.c

示例4: TA_GroupTableAlloc

/**** Global functions definitions.   ****/
TA_RetCode TA_GroupTableAlloc( TA_Libc *libHandle, TA_StringTable **table )
{
   TA_PROLOG;
   TA_StringTable *stringTable;
   TA_StringTableGroupHidden *stringTableHidden;

   TA_TRACE_BEGIN( libHandle, TA_GroupTableAlloc );

   if( table == NULL )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   *table = NULL;

   stringTable = (TA_StringTable *)TA_Malloc( libHandle, sizeof(TA_StringTable) );

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

   stringTableHidden = (TA_StringTableGroupHidden *)TA_Malloc( libHandle, sizeof(TA_StringTableGroupHidden) );
   if( !stringTableHidden )
   {
      TA_Free( libHandle, stringTable );
      TA_TRACE_RETURN( TA_ALLOC_ERR );
   }

   stringTableHidden->libHandle = libHandle;
   stringTableHidden->magicNb = TA_STRING_TABLE_GROUP_MAGIC_NB;
   stringTable->size = TA_NB_GROUP_ID;
   stringTable->string = &TA_GroupString[0];
   stringTable->hiddenData = stringTableHidden;

   /* From this point, TA_FuncTableFree can be safely called. */

   /* Success. Return the table to the caller. */
   *table = stringTable;

   TA_TRACE_RETURN( TA_SUCCESS );
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:43,代码来源:ta_abstract.c

示例5: TA_FileIndexAddTokenInfo

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 );
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:52,代码来源:ta_fileindex_priv.c

示例6: TA_GetGlobalStringCache

/**** Local functions definitions.     ****/
static TA_ValueTreeNode *allocTreeNode( TA_Libc *libHandle,
                                        TA_ValueTreeNode *parent,
                                        TA_String *string )
{
   TA_ValueTreeNode *node;
   TA_RetCode retCode;
   TA_StringCache *stringCache;

   stringCache = TA_GetGlobalStringCache( libHandle );

   node = (TA_ValueTreeNode *)TA_Malloc( libHandle, sizeof( TA_ValueTreeNode ) );

   if( !node )
      return (TA_ValueTreeNode *)NULL;

   node->string = NULL;
   node->parent = NULL;

   node->child = TA_ListAlloc( libHandle );
   if( !node->child )
   {
      freeTreeNode( libHandle, node );
      return NULL;
   }

   if( string )
   {
      node->string = TA_StringDup( stringCache, string );
      if( !node->string )
      {
         freeTreeNode( libHandle, node );
         return NULL;
      }
   }

   if( parent )
   {
      retCode = TA_ListAddTail( parent->child, node );
      if( retCode != TA_SUCCESS )
      {
         freeTreeNode( libHandle, node );
         return NULL;
      }
      node->parent = parent;
   }

   return node;
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:49,代码来源:ta_fileindex_priv.c

示例7: TA_ParamHolderAlloc

TA_RetCode TA_ParamHolderAlloc( const TA_FuncHandle *handle,
                                TA_ParamHolder **allocatedParams )
{
   
   TA_FuncDef *funcDef;
   unsigned int allocSize, i;
   TA_ParamHolderInput    *input;
   TA_ParamHolderOptInput *optInput;
   TA_ParamHolderOutput   *output;

   const TA_FuncInfo *funcInfo;
   TA_ParamHolder *newParams;
   TA_ParamHolderPriv *newParamsPriv;

   const TA_InputParameterInfo    **inputInfo;
   const TA_OptInputParameterInfo **optInputInfo;
   const TA_OutputParameterInfo   **outputInfo;

   /* Validate the parameters. */
   if( !handle || !allocatedParams)
   {
      return TA_BAD_PARAM;
   }

   /* Validate that this is a valid funcHandle. */
   funcDef = (TA_FuncDef *)handle;
   if( funcDef->magicNumber != TA_FUNC_DEF_MAGIC_NB )
   {
      *allocatedParams = NULL;
      return TA_INVALID_HANDLE;
   }

   /* Get the TA_FuncInfo. */
   funcInfo = funcDef->funcInfo;
   if( !funcInfo ) return TA_INVALID_HANDLE;

   /* Allocate the TA_ParamHolder. */
   newParams = (TA_ParamHolder *)TA_Malloc( sizeof(TA_ParamHolder) + sizeof(TA_ParamHolderPriv));
   if( !newParams )
   {
      *allocatedParams = NULL;
      return TA_ALLOC_ERR;
   }

   memset( newParams, 0, sizeof(TA_ParamHolder) + sizeof(TA_ParamHolderPriv) );
   newParamsPriv = (TA_ParamHolderPriv *)(((char *)newParams)+sizeof(TA_ParamHolder));
   newParamsPriv->magicNumber = TA_PARAM_HOLDER_PRIV_MAGIC_NB;
   newParams->hiddenData = newParamsPriv;

   /* From this point, TA_ParamHolderFree can be safely called. */

   /* Allocate the array of structure holding the info
    * for each parameter.
    */
   if( funcInfo->nbInput == 0 ) return TA_INTERNAL_ERROR(2);

   allocSize = (funcInfo->nbInput) * sizeof(TA_ParamHolderInput);
   input = (TA_ParamHolderInput *)TA_Malloc( allocSize );

   if( !input )
   {
      TA_ParamHolderFree( newParams );
      *allocatedParams = NULL;
      return TA_ALLOC_ERR;
   }
   memset( input, 0, allocSize );
   newParamsPriv->in = input;

   if( funcInfo->nbOptInput == 0 )
      optInput = NULL;
   else
   {
      allocSize = (funcInfo->nbOptInput) * sizeof(TA_ParamHolderOptInput);
      optInput = (TA_ParamHolderOptInput *)TA_Malloc( allocSize );

      if( !optInput )
      {
         TA_ParamHolderFree( newParams );
         *allocatedParams = NULL;
         return TA_ALLOC_ERR;
      }
      memset( optInput, 0, allocSize );
   }
   newParamsPriv->optIn = optInput;

   allocSize = (funcInfo->nbOutput) * sizeof(TA_ParamHolderOutput);
   output = (TA_ParamHolderOutput *)TA_Malloc( allocSize );
   if( !output )
   {
      TA_ParamHolderFree( newParams );
      *allocatedParams = NULL;
      return TA_ALLOC_ERR;
   }
   memset( output, 0, allocSize );
   newParamsPriv->out = output;

   newParamsPriv->funcInfo = funcInfo;

   inputInfo    = (const TA_InputParameterInfo **)funcDef->input;
   optInputInfo = (const TA_OptInputParameterInfo **)funcDef->optInput;
//.........这里部分代码省略.........
开发者ID:BestSean2016,项目名称:ta-lib,代码行数:101,代码来源:ta_abstract.c

示例8: TA_FuncTableAlloc

TA_RetCode TA_FuncTableAlloc( const char *group, TA_StringTable **table )
{
   TA_RetCode retCode;
   unsigned int i;
   TA_StringTable *stringTable;
   unsigned int groupId; /* TA_GroupId */
   unsigned int groupSize;
   const char *stringPtr;
   TA_StringTablePriv *stringTablePriv;

   if( (group == NULL) || (table == NULL ) )
   {
      return TA_BAD_PARAM;
   }

   *table = NULL;
   stringPtr = NULL;

   /* Get information on the group. */
   retCode = getGroupId( group, &groupId );
   if( retCode != TA_SUCCESS )
   {
      return retCode;
   }

   retCode = getGroupSize( (TA_GroupId)groupId, &groupSize );
   if( retCode != TA_SUCCESS )
   {
      return retCode;
   }

   /* Allocate the table. */

   stringTable = (TA_StringTable *)TA_Malloc( sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   if( !stringTable )
   {
      *table = NULL;
      return TA_ALLOC_ERR;
   }

   memset( stringTable, 0, sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   stringTablePriv = (TA_StringTablePriv *)(((char *)stringTable)+sizeof(TA_StringTable));
   stringTablePriv->magicNumber = TA_STRING_TABLE_FUNC_MAGIC_NB;
   stringTable->hiddenData = stringTablePriv;

   /* From this point, TA_FuncTableFree can be safely called. */
   stringTable->size = groupSize;
   if( groupSize != 0 )
   {
      stringTable->string = (const char **)TA_Malloc( (stringTable->size) *
                                                      sizeof(const char *) );

      if( stringTable->string == NULL )
      {
         *table = NULL;
         TA_FuncTableFree( stringTable );
         return TA_ALLOC_ERR;
      }

      memset( (void *)stringTable->string, 0,
              (stringTable->size) * sizeof(const char *) );

      for( i=0; i < stringTable->size; i++ )
      {
         retCode = getFuncNameByIdx( (TA_GroupId)groupId, i, &stringPtr );

         if( retCode != TA_SUCCESS )
         {
            *table = NULL;
            TA_FuncTableFree( stringTable );
            return TA_ALLOC_ERR;
         }

         (stringTable->string)[i] = stringPtr;
      }
   }

   /* Return the table to the caller. */
   *table = stringTable;

   return TA_SUCCESS;
}
开发者ID:BestSean2016,项目名称:ta-lib,代码行数:82,代码来源:ta_abstract.c

示例9: rangeTestFunction

/**** Local functions definitions.     ****/
static TA_RetCode rangeTestFunction( TA_Libc *libHandle, 
                              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 *dummyOutput;
  
  testParam = (TA_RangeTestParam *)opaqueData;   


  dummyOutput = TA_Malloc( libHandle, (endIdx-startIdx+1) * sizeof(TA_Real) );

  if( outputNb == 0 )
  {
     retCode = TA_STOCH( libHandle,
                         startIdx,
                         endIdx,
                         testParam->high,
                         testParam->low,
                         testParam->close,
                         testParam->test->optInKPeriod_0,
                         testParam->test->optInKSlowPeriod_1,
                         testParam->test->optInDPeriod_2,
                         testParam->test->optInMethod_3,                       
                         outBegIdx, outNbElement,
                         outputBuffer,
                         dummyOutput );

   }
   else
   {
     retCode = TA_STOCH( libHandle,
                         startIdx,
                         endIdx,
                         testParam->high,
                         testParam->low,
                         testParam->close,
                         testParam->test->optInKPeriod_0,
                         testParam->test->optInKSlowPeriod_1,
                         testParam->test->optInDPeriod_2,
                         testParam->test->optInMethod_3,                                                
                         outBegIdx, outNbElement,
                         dummyOutput, 
                         outputBuffer );
   }

   TA_Free( libHandle, dummyOutput );

   *lookback = TA_STOCH_Lookback( testParam->test->optInKPeriod_0,
                         testParam->test->optInKSlowPeriod_1,
                         testParam->test->optInDPeriod_2,
                         testParam->test->optInMethod_3 );

   return retCode;
}
开发者ID:royratcliffe,项目名称:ta-lib,代码行数:63,代码来源:test_stoch.c


注:本文中的TA_Malloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。