您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ traceMALLOC函数代码示例

51自学网 2021-06-03 08:56:18
  C++
这篇教程C++ traceMALLOC函数代码示例写得很实用,希望能帮到您。

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

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

示例1: vTaskSuspendAll

void *pvPortMalloc( size_t xWantedSize ){void *pvReturn = NULL;static uint8_t *pucAlignedHeap = NULL;	/* Ensure that blocks are always aligned to the required number of bytes. */	#if( portBYTE_ALIGNMENT != 1 )	{		if( xWantedSize & portBYTE_ALIGNMENT_MASK )		{			/* Byte alignment required. */			xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );		}	}	#endif	vTaskSuspendAll();	{		if( pucAlignedHeap == NULL )		{			/* Ensure the heap starts on a correctly aligned boundary. */			pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );		}		/* Check there is enough room left for the allocation. */		if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&			( ( xNextFreeByte + xWantedSize ) > xNextFreeByte )	)/* Check for overflow. */		{			/* Return the next free byte then increment the index past this			block. */			pvReturn = pucAlignedHeap + xNextFreeByte;			xNextFreeByte += xWantedSize;		}		traceMALLOC( pvReturn, xWantedSize );	}	( void ) xTaskResumeAll();	#if( configUSE_MALLOC_FAILED_HOOK == 1 )	{		if( pvReturn == NULL )		{		  /* EST: Using configuration macro name for hook */			extern void configUSE_MALLOC_FAILED_HOOK_NAME( void );      configUSE_MALLOC_FAILED_HOOK_NAME();		}	}	#endif	return pvReturn;}
开发者ID:alsancho,项目名称:mcuoneclipse,代码行数:51,


示例2: vTaskSuspendAll

void *pvPortMalloc( size_t xWantedSize ){void *pvReturn;	vTaskSuspendAll();	{		pvReturn = malloc( xWantedSize );		traceMALLOC( pvReturn, xWantedSize );	}	(void)xTaskResumeAll();	#if( configUSE_MALLOC_FAILED_HOOK == 1 )	{		if( pvReturn == NULL )		{      FRTOS1_vApplicationMallocFailedHook();		}	}	#endif		return pvReturn;}
开发者ID:fsoo,项目名称:TabataTimer,代码行数:22,


示例3: vTaskSuspendAll

void *pvPortMalloc( size_t xWantedSize ){BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;static BaseType_t xHeapHasBeenInitialised = pdFALSE;void *pvReturn = NULL;	vTaskSuspendAll();	{		/* If this is the first call to malloc then the heap will require		initialisation to setup the list of free blocks. */		if( xHeapHasBeenInitialised == pdFALSE )		{			prvHeapInit();			xHeapHasBeenInitialised = pdTRUE;		}		/* The wanted size is increased so it can contain a BlockLink_t		structure in addition to the requested amount of bytes. */		if( xWantedSize > 0 )		{			xWantedSize += heapSTRUCT_SIZE;			/* Ensure that blocks are always aligned to the required number of bytes. */			if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 )			{				/* Byte alignment required. */				xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );			}		}		if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) )		{			/* Blocks are stored in byte order - traverse the list from the start			(smallest) block until one of adequate size is found. */			pxPreviousBlock = &xStart;			pxBlock = xStart.pxNextFreeBlock;			while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )			{				pxPreviousBlock = pxBlock;				pxBlock = pxBlock->pxNextFreeBlock;			}			/* If we found the end marker then a block of adequate size was not found. */			if( pxBlock != &xEnd )			{				/* Return the memory space - jumping over the BlockLink_t structure				at its start. */				pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );				/* This block is being returned for use so must be taken out of the				list of free blocks. */				pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;				/* If the block is larger than required it can be split into two. */				if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )				{					/* This block is to be split into two.  Create a new block					following the number of bytes requested. The void cast is					used to prevent byte alignment warnings from the compiler. */					pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );					/* Calculate the sizes of two blocks split from the single					block. */					pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;					pxBlock->xBlockSize = xWantedSize;					/* Insert the new block into the list of free blocks. */					prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );				}				xFreeBytesRemaining -= pxBlock->xBlockSize;			}		}		traceMALLOC( pvReturn, xWantedSize );	}	( void ) xTaskResumeAll();	#if( configUSE_MALLOC_FAILED_HOOK == 1 )	{		if( pvReturn == NULL )		{			extern void vApplicationMallocFailedHook( void );			vApplicationMallocFailedHook();		}	}	#endif	return pvReturn;}
开发者ID:AaronCohen1,项目名称:temp-497.31,代码行数:90,


示例4: vTaskSuspendAll

//.........这里部分代码省略.........            if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )            {                /* Traverse the list from the start	(lowest address) block until                one	of adequate size is found. */                pxPreviousBlock = &xStart;                pxBlock = xStart.pxNextFreeBlock;                while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )                {                    pxPreviousBlock = pxBlock;                    pxBlock = pxBlock->pxNextFreeBlock;                }                /* If the end marker was reached then a block of adequate size                was	not found. */                if( pxBlock != pxEnd )                {                    /* Return the memory space pointed to - jumping over the                    BlockLink_t structure at its start. */                    pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );                    /* This block is being returned for use so must be taken out                    of the list of free blocks. */                    pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;                    /* If the block is larger than required it can be split into                    two. */                    if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )                    {                        /* This block is to be split into two.  Create a new                        block following the number of bytes requested. The void                        cast is used to prevent byte alignment warnings from the                        compiler. */                        pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );                        configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );                        /* Calculate the sizes of two blocks split from the                        single block. */                        pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;                        pxBlock->xBlockSize = xWantedSize;                        /* Insert the new block into the list of free blocks. */                        prvInsertBlockIntoFreeList( pxNewBlockLink );                    }                    else                    {                        mtCOVERAGE_TEST_MARKER();                    }                    xFreeBytesRemaining -= pxBlock->xBlockSize;                    if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )                    {                        xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;                    }                    else                    {                        mtCOVERAGE_TEST_MARKER();                    }                    /* The block is being returned - it is allocated and owned                    by the application and has no "next" block. */                    pxBlock->xBlockSize |= xBlockAllocatedBit;                    pxBlock->pxNextFreeBlock = NULL;                }                else                {                    mtCOVERAGE_TEST_MARKER();                }            }            else            {                mtCOVERAGE_TEST_MARKER();            }        }        else        {            mtCOVERAGE_TEST_MARKER();        }        traceMALLOC( pvReturn, xWantedSize );    }    ( void ) xTaskResumeAll();#if( configUSE_MALLOC_FAILED_HOOK == 1 )    {        if( pvReturn == NULL )        {            extern void vApplicationMallocFailedHook( void );            vApplicationMallocFailedHook();        }        else        {            mtCOVERAGE_TEST_MARKER();        }    }#endif    configASSERT( ( ( ( size_t ) pvReturn ) & ( size_t ) portBYTE_ALIGNMENT_MASK ) == 0 );    return pvReturn;}
开发者ID:RidleyWalker,项目名称:micropython,代码行数:101,


示例5: vPortDefineHeapRegions

//.........这里部分代码省略.........					pxPreviousBlock = pxBlock;					pxBlock = pxBlock->pxNextFreeBlock;				}				/* If the end marker was reached then a block of adequate size				was	not found. */				if( pxBlock != pxEnd )				{					/* Return the memory space pointed to - jumping over the					BlockLink_t structure at its start. */					pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + uxHeapStructSize );					/* This block is being returned for use so must be taken out					of the list of free blocks. */					pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;					/* If the block is larger than required it can be split into					two. */					if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )					{						/* This block is to be split into two.  Create a new						block following the number of bytes requested. The void						cast is used to prevent byte alignment warnings from the						compiler. */						pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );						/* Calculate the sizes of two blocks split from the						single block. */						pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;						pxBlock->xBlockSize = xWantedSize;						/* Insert the new block into the list of free blocks. */						prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );					}					else					{						mtCOVERAGE_TEST_MARKER();					}					xFreeBytesRemaining -= pxBlock->xBlockSize;					if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )					{						xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;					}					else					{						mtCOVERAGE_TEST_MARKER();					}					/* The block is being returned - it is allocated and owned					by the application and has no "next" block. */					pxBlock->xBlockSize |= xBlockAllocatedBit;					pxBlock->pxNextFreeBlock = NULL;                    #ifdef MEMLEAK_DEBUG					if(uxHeapStructSize >= sizeof( BlockLink_t )){						pxBlock->file = file;						pxBlock->line = line;					}					//link the use block					prvInsertBlockIntoUsedList(pxBlock);#endif				}				else				{					mtCOVERAGE_TEST_MARKER();				}			}			else			{				mtCOVERAGE_TEST_MARKER();			}		}		else		{			mtCOVERAGE_TEST_MARKER();		}		traceMALLOC( pvReturn, xWantedSize );	}	// ( void ) xTaskResumeAll();    ETS_INTR_UNLOCK();	#if( configUSE_MALLOC_FAILED_HOOK == 1 )	{		if( pvReturn == NULL )		{			extern void vApplicationMallocFailedHook( void );			vApplicationMallocFailedHook();		}		else		{			mtCOVERAGE_TEST_MARKER();		}	}	#endif	return pvReturn;}
开发者ID:karawin,项目名称:Ka-Radio,代码行数:101,



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


C++ traceMsg函数代码示例
C++ traceLastFunc函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。