这篇教程C++ utMalloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中utMalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ utMalloc函数的具体用法?C++ utMalloc怎么用?C++ utMalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了utMalloc函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mdlStart_c2_DYNctl_ver4_etud_nonlineairestatic void mdlStart_c2_DYNctl_ver4_etud_nonlineaire(SimStruct *S){ SFc2_DYNctl_ver4_etud_nonlineaireInstanceStruct *chartInstance; ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)utMalloc(sizeof (ChartRunTimeInfo)); chartInstance = (SFc2_DYNctl_ver4_etud_nonlineaireInstanceStruct *)utMalloc (sizeof(SFc2_DYNctl_ver4_etud_nonlineaireInstanceStruct)); memset(chartInstance, 0, sizeof (SFc2_DYNctl_ver4_etud_nonlineaireInstanceStruct)); if (chartInstance==NULL) { sf_mex_error_message("Could not allocate memory for chart instance."); } chartInstance->chartInfo.chartInstance = chartInstance; chartInstance->chartInfo.isEMLChart = 1; chartInstance->chartInfo.chartInitialized = 0; chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.enableChart = sf_opaque_enable_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.disableChart = sf_opaque_disable_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.zeroCrossings = NULL; chartInstance->chartInfo.outputs = NULL; chartInstance->chartInfo.derivatives = NULL; chartInstance->chartInfo.mdlRTW = mdlRTW_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.mdlStart = mdlStart_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c2_DYNctl_ver4_etud_nonlineaire; chartInstance->chartInfo.extModeExec = NULL; chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL; chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL; chartInstance->chartInfo.storeCurrentConfiguration = NULL; chartInstance->chartInfo.callAtomicSubchartUserFcn = NULL; chartInstance->chartInfo.callAtomicSubchartAutoFcn = NULL; chartInstance->chartInfo.debugInstance = sfGlobalDebugInstanceStruct; chartInstance->S = S; crtInfo->checksum = SF_RUNTIME_INFO_CHECKSUM; crtInfo->instanceInfo = (&(chartInstance->chartInfo)); crtInfo->isJITEnabled = false; crtInfo->compiledInfo = NULL; ssSetUserData(S,(void *)(crtInfo)); /* register the chart instance with simstruct */ init_dsm_address_info(chartInstance); init_simulink_io_address(chartInstance); if (!sim_mode_is_rtw_gen(S)) { } sf_opaque_init_subchart_simstructs(chartInstance->chartInfo.chartInstance); chart_debug_initialization(S,1);}
开发者ID:bmaxb,项目名称:projet_s4,代码行数:60,
示例2: rtwCAPI_UpdateFullPaths/** Function: rtwCAPI_UpdateFullPaths =========================================* * */const char_T* rtwCAPI_UpdateFullPaths(rtwCAPI_ModelMappingInfo* mmi, const char_T* path, boolean_T isCalledFromTopModel){ int_T i; int_T nCMMI; size_t pathLen; char_T* mmiPath; size_t mmiPathLen; char_T* relMMIPath; size_t relMMIPathLen; if (mmi == NULL) return NULL; utAssert(path != NULL); utAssert( rtwCAPI_GetFullPath(mmi) == NULL ); pathLen = strlen(path)+1; if (isCalledFromTopModel) { /* If called from top model - FullPath is same as path */ mmiPath = (char_T*)utMalloc(pathLen*sizeof(char_T)); (void)memcpy(mmiPath, path, pathLen*sizeof(char_T)); } else { relMMIPath = rtwCAPI_EncodePath(rtwCAPI_GetPath(mmi)); if ( (relMMIPath== NULL) && (rtwCAPI_GetPath(mmi) != NULL)) { return rtwCAPI_mallocError; } relMMIPathLen = relMMIPath ? (strlen(relMMIPath) + 1) : 0; mmiPathLen = pathLen + relMMIPathLen; mmiPath = (char_T*)utMalloc(mmiPathLen*sizeof(char_T)); if (mmiPath == NULL) return rtwCAPI_mallocError; (void)memcpy(mmiPath, path, pathLen*sizeof(char_T)); utAssert(mmiPath[pathLen-1] == '/0'); if (relMMIPath) { /* mmiPath = path + | + relMMIPath + '/0' */ mmiPath[pathLen-1] = '|'; (void)memcpy(&(mmiPath[pathLen]), relMMIPath, relMMIPathLen*sizeof(char_T)); utAssert(mmiPath[mmiPathLen-1] == '/0'); utFree(relMMIPath); } } rtwCAPI_SetFullPath(*mmi, mmiPath); nCMMI = rtwCAPI_GetChildMMIArrayLen(mmi); for (i = 0; i < nCMMI; ++i) { rtwCAPI_ModelMappingInfo* cMMI = rtwCAPI_GetChildMMI(mmi,i); const char_T* errstr = rtwCAPI_UpdateFullPaths(cMMI, mmiPath, 0); if (errstr != NULL) return errstr; } return NULL;} /* rtwCAPI_UpdateFullPaths */
开发者ID:Shedino,项目名称:Firmware,代码行数:61,
示例3: mdlStart_c13_ARP_02_RPSs_Bdr_GK_BIS5static void mdlStart_c13_ARP_02_RPSs_Bdr_GK_BIS5(SimStruct *S){ SFc13_ARP_02_RPSs_Bdr_GK_BIS5InstanceStruct *chartInstance; ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)utMalloc(sizeof (ChartRunTimeInfo)); chartInstance = (SFc13_ARP_02_RPSs_Bdr_GK_BIS5InstanceStruct *)utMalloc(sizeof (SFc13_ARP_02_RPSs_Bdr_GK_BIS5InstanceStruct)); memset(chartInstance, 0, sizeof(SFc13_ARP_02_RPSs_Bdr_GK_BIS5InstanceStruct)); if (chartInstance==NULL) { sf_mex_error_message("Could not allocate memory for chart instance."); } chartInstance->chartInfo.chartInstance = chartInstance; chartInstance->chartInfo.isEMLChart = 1; chartInstance->chartInfo.chartInitialized = 0; chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.enableChart = sf_opaque_enable_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.disableChart = sf_opaque_disable_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.zeroCrossings = NULL; chartInstance->chartInfo.outputs = NULL; chartInstance->chartInfo.derivatives = NULL; chartInstance->chartInfo.mdlRTW = mdlRTW_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.mdlStart = mdlStart_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c13_ARP_02_RPSs_Bdr_GK_BIS5; chartInstance->chartInfo.extModeExec = NULL; chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL; chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL; chartInstance->chartInfo.storeCurrentConfiguration = NULL; chartInstance->chartInfo.debugInstance = sfGlobalDebugInstanceStruct; chartInstance->S = S; crtInfo->instanceInfo = (&(chartInstance->chartInfo)); crtInfo->isJITEnabled = false; ssSetUserData(S,(void *)(crtInfo)); /* register the chart instance with simstruct */ init_dsm_address_info(chartInstance); if (!sim_mode_is_rtw_gen(S)) { } sf_opaque_init_subchart_simstructs(chartInstance->chartInfo.chartInstance); chart_debug_initialization(S,1);}
开发者ID:maryamsab,项目名称:realact,代码行数:54,
示例4: rtwCAPI_EncodePath/** Function: rtwCAPI_EncodePath =============================================== * Abatract: * Escape all '|' characters in bpath. For examples 'aaa|b' will become * 'aaa~|b'. The caller is responsible for freeing the returned string * * * NOTE: returned string can be NULL in two cases: * (1) string passed in was NULL * (2) a memory allocation error occurred * In the second case, the caller need to report the error */char* rtwCAPI_EncodePath(const char* path){ char* encodedPath = NULL; size_t pathLen = (path==NULL) ? 0:strlen(path) + 1; size_t encodedPathLen = pathLen; unsigned i; unsigned j = 0; if (path == NULL) return NULL; for (i = 0; i < pathLen; ++i) { if (path[i] == '|' || path[i] == '~') ++encodedPathLen; } encodedPath = (char_T*)utMalloc(encodedPathLen*sizeof(char_T)); if (encodedPath == NULL) return encodedPath; for (i = 0; i < pathLen; ++i) { char ch = path[i]; if (ch == '~' || ch == '|') encodedPath[j++] = '~'; encodedPath[j++] = ch; } utAssert(j == encodedPathLen); utAssert(encodedPath[j-1] == '/0'); return encodedPath;} /* rtwCAPI_EncodePath */
开发者ID:Shedino,项目名称:Firmware,代码行数:39,
示例5: rtwCAPI_GetFullStateBlockPath/** Function: rtwCAPI_GetFullStateBlockPath =================================== * */char* rtwCAPI_GetFullStateBlockPath(const char* stateBlockPath, const char* mmiPath, size_t mmiPathLen, boolean_T crossingModel){ char_T* blockPath = NULL; char_T* fullStateBlockPath = NULL; size_t fullStateBlockPathLen; if (stateBlockPath == NULL) goto EXIT_POINT; /* fullStateBlockPath = mmiPath + | + blockPath + '/0' */ /* If crossing a model boundary encode, otherwise do not */ if (crossingModel) { blockPath = rtwCAPI_EncodePath(stateBlockPath); if (blockPath == NULL) goto EXIT_POINT; } else { size_t len = strlen(stateBlockPath)+1; blockPath = (char*)utMalloc(len*sizeof(char)); if (blockPath == NULL) goto EXIT_POINT; (void)strcpy(blockPath,stateBlockPath); } utAssert(blockPath != NULL); fullStateBlockPathLen = ( (mmiPath==NULL) ? strlen(blockPath) + 1 : mmiPathLen + strlen(blockPath) + 2 ); fullStateBlockPath = (char*)utMalloc(fullStateBlockPathLen*sizeof(char)); if (fullStateBlockPath == NULL) goto EXIT_POINT; if (mmiPath != NULL) { (void)strcpy(fullStateBlockPath, mmiPath); fullStateBlockPath[mmiPathLen] = '|'; fullStateBlockPath[mmiPathLen+1] = '/0'; (void)strcat(fullStateBlockPath, blockPath); } else { (void)strcpy(fullStateBlockPath, blockPath); fullStateBlockPath[fullStateBlockPathLen-1] = '/0'; } utAssert(fullStateBlockPath[fullStateBlockPathLen-1] == '/0'); EXIT_POINT: utFree(blockPath); return fullStateBlockPath; /* caller is responsible for free */}
开发者ID:Shedino,项目名称:Firmware,代码行数:48,
示例6: mdlStart_c2_MigrationOWBG_Proto4_1DLinear2DNonLinearstatic void mdlStart_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear(SimStruct *S){ SFc2_MigrationOWBG_Proto4_1DLinear2DNonLinearInstanceStruct *chartInstance; chartInstance = (SFc2_MigrationOWBG_Proto4_1DLinear2DNonLinearInstanceStruct *) utMalloc(sizeof(SFc2_MigrationOWBG_Proto4_1DLinear2DNonLinearInstanceStruct)); memset(chartInstance, 0, sizeof (SFc2_MigrationOWBG_Proto4_1DLinear2DNonLinearInstanceStruct)); if (chartInstance==NULL) { sf_mex_error_message("Could not allocate memory for chart instance."); } chartInstance->chartInfo.chartInstance = chartInstance; chartInstance->chartInfo.isEMLChart = 1; chartInstance->chartInfo.chartInitialized = 0; chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.enableChart = sf_opaque_enable_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.disableChart = sf_opaque_disable_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.zeroCrossings = NULL; chartInstance->chartInfo.outputs = NULL; chartInstance->chartInfo.derivatives = NULL; chartInstance->chartInfo.mdlRTW = mdlRTW_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.mdlStart = mdlStart_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c2_MigrationOWBG_Proto4_1DLinear2DNonLinear; chartInstance->chartInfo.extModeExec = NULL; chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL; chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL; chartInstance->chartInfo.storeCurrentConfiguration = NULL; chartInstance->S = S; ssSetUserData(S,(void *)(&(chartInstance->chartInfo)));/* register the chart instance with simstruct */ init_dsm_address_info(chartInstance); if (!sim_mode_is_rtw_gen(S)) { } sf_opaque_init_subchart_simstructs(chartInstance->chartInfo.chartInstance); chart_debug_initialization(S,1);}
开发者ID:ryangrnr,项目名称:3rd-Year-Project,代码行数:52,
示例7: Deadbeat_CUK_acc_rt_TDelayUpdateTailOrGrowBufboolean_T Deadbeat_CUK_acc_rt_TDelayUpdateTailOrGrowBuf ( int_T * bufSzPtr ,int_T * tailPtr , int_T * headPtr , int_T * lastPtr , real_T tMinusDelay ,real_T * * tBufPtr , real_T * * uBufPtr , real_T * * xBufPtr , boolean_Tisfixedbuf , boolean_T istransportdelay , int_T * maxNewBufSzPtr ) { int_TtestIdx ; int_T tail = * tailPtr ; int_T bufSz = * bufSzPtr ; real_T * tBuf =* tBufPtr ; real_T * xBuf = ( NULL ) ; int_T numBuffer = 2 ; if (istransportdelay ) { numBuffer = 3 ; xBuf = * xBufPtr ; } testIdx = ( tail <( bufSz - 1 ) ) ? ( tail + 1 ) : 0 ; if ( ( tMinusDelay <= tBuf [ testIdx ] )&& ! isfixedbuf ) { int_T j ; real_T * tempT ; real_T * tempU ; real_T *tempX = ( NULL ) ; real_T * uBuf = * uBufPtr ; int_T newBufSz = bufSz + 1024; if ( newBufSz > * maxNewBufSzPtr ) { * maxNewBufSzPtr = newBufSz ; } tempU= ( real_T * ) utMalloc ( numBuffer * newBufSz * sizeof ( real_T ) ) ; if (tempU == ( NULL ) ) { return ( false ) ; } tempT = tempU + newBufSz ; if (istransportdelay ) tempX = tempT + newBufSz ; for ( j = tail ; j < bufSz ; j++ ) { tempT [ j - tail ] = tBuf [ j ] ; tempU [ j - tail ] = uBuf [ j ] ; if( istransportdelay ) tempX [ j - tail ] = xBuf [ j ] ; } for ( j = 0 ; j <tail ; j ++ ) { tempT [ j + bufSz - tail ] = tBuf [ j ] ; tempU [ j + bufSz -tail ] = uBuf [ j ] ; if ( istransportdelay ) tempX [ j + bufSz - tail ] =xBuf [ j ] ; } if ( * lastPtr > tail ) { * lastPtr -= tail ; } else { *lastPtr += ( bufSz - tail ) ; } * tailPtr = 0 ; * headPtr = bufSz ; utFree (uBuf ) ; * bufSzPtr = newBufSz ; * tBufPtr = tempT ; * uBufPtr = tempU ; if (istransportdelay ) * xBufPtr = tempX ; } else { * tailPtr = testIdx ; }return ( true ) ; } real_T Deadbeat_CUK_acc_rt_TDelayInterpolate ( real_T
开发者ID:Velocar,项目名称:Bikair_MBD,代码行数:23,
示例8: rtwCAPI_GetSigLogRecordInfo/** Function: rtwCAPI_GetSigLogRecordInfo ====================================== * */const char_T* rtwCAPI_GetSigLogRecordInfo(const rtwCAPI_ModelMappingInfo* mmi, const char_T** sigBlockName, const char_T** sigLabel, int_T* sigWidth, int_T* sigDataType, int_T* logDataType, int_T* sigComplexity, void** sigDataAddr, boolean_T* sigCrossMdlRef, int_T* sigIdx, boolean_T crossingModel, boolean_T rtwLogging){ int_T i; int_T nCMMI; int_T nSignals; const char_T* mmiPath; size_t mmiPathLen; const rtwCAPI_Signals* signals; const rtwCAPI_DimensionMap* dimMap; const uint_T* dimArray; const rtwCAPI_DataTypeMap* dataTypeMap; void** dataAddrMap; const char_T* errstr = NULL; uint8_T isPointer = 0; char* blockPath = NULL; if (mmi == NULL) goto EXIT_POINT; nCMMI = rtwCAPI_GetChildMMIArrayLen(mmi); for (i = 0; i < nCMMI; ++i) { rtwCAPI_ModelMappingInfo* cMMI = rtwCAPI_GetChildMMI(mmi,i); errstr = rtwCAPI_GetSigLogRecordInfo(cMMI, sigBlockName, sigLabel, sigWidth, sigDataType, logDataType, sigComplexity, sigDataAddr, sigCrossMdlRef, sigIdx, true, rtwLogging); if (errstr != NULL) goto EXIT_POINT; } nSignals = rtwCAPI_GetNumSignals(mmi); if (nSignals < 1) goto EXIT_POINT; mmiPath = rtwCAPI_GetFullPath(mmi); mmiPathLen = (mmiPath==NULL)? 0 : strlen(mmiPath); signals = rtwCAPI_GetSignals(mmi); dimMap = rtwCAPI_GetDimensionMap(mmi); dimArray = rtwCAPI_GetDimensionArray(mmi); dataTypeMap = rtwCAPI_GetDataTypeMap(mmi); dataAddrMap = rtwCAPI_GetDataAddressMap(mmi); for (i = 0; i < nSignals; ++i) { uint_T mapIdx; size_t sigPathLen; char* sigPath; /* For RTW logging, skip states that cannot be logged to MAT-File. */ if ((rtwLogging) && (rtwCAPI_CanLogSignalToMATFile(dataTypeMap, signals, i) == false)) continue; /* sigBlockPath = mmiPath + | + BlockPath + '/0' */ /* If crossing a model boundary encode, otherwise do not */ if (crossingModel) { blockPath = rtwCAPI_EncodePath(rtwCAPI_GetSignalBlockPath(signals, i)); if ( (blockPath == NULL) && (rtwCAPI_GetSignalBlockPath(signals, i) != NULL)) { errstr = rtwCAPI_mallocError; goto EXIT_POINT; } } else { const char* constBlockPath = rtwCAPI_GetSignalBlockPath(signals, i); blockPath = (char*)utMalloc((strlen(constBlockPath)+1)*sizeof(char)); (void)strcpy(blockPath, constBlockPath); } utAssert(blockPath != NULL); sigPathLen = ( (mmiPath==NULL) ? strlen(blockPath) + 1 : mmiPathLen + strlen(blockPath) + 2 ); sigPath = (char*)utMalloc(sigPathLen*sizeof(char)); if (sigPath == NULL) { errstr = rtwCAPI_mallocError; goto EXIT_POINT; } if (mmiPath != NULL) { (void)strcpy(sigPath, mmiPath); sigPath[mmiPathLen] = '|'; sigPath[mmiPathLen+1] = '/0'; (void)strcat(sigPath, blockPath);//.........这里部分代码省略.........
开发者ID:Shedino,项目名称:Firmware,代码行数:101,
注:本文中的utMalloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ut_a函数代码示例 C++ utFree函数代码示例 |