亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? heap_2.c

?? Modbus協(xié)議的源代碼 Modbus協(xié)議的源代碼、 Modbus協(xié)議的源代碼 Modbus協(xié)議的源代碼
?? C
字號:
/*

	FreeRTOS.org V4.1.1 - Copyright (C) 2003-2006 Richard Barry.



	This file is part of the FreeRTOS.org distribution.



	FreeRTOS.org is free software; you can redistribute it and/or modify

	it under the terms of the GNU General Public License as published by

	the Free Software Foundation; either version 2 of the License, or

	(at your option) any later version.



	FreeRTOS.org is distributed in the hope that it will be useful,

	but WITHOUT ANY WARRANTY; without even the implied warranty of

	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

	GNU General Public License for more details.



	You should have received a copy of the GNU General Public License

	along with FreeRTOS.org; if not, write to the Free Software

	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



	A special exception to the GPL can be applied should you wish to distribute

	a combined work that includes FreeRTOS.org, without being obliged to provide

	the source code for any proprietary components.  See the licensing section

	of http://www.FreeRTOS.org for full details of how and when the exception

	can be applied.



	***************************************************************************

	See http://www.FreeRTOS.org for documentation, latest information, license

	and contact details.  Please ensure to read the configuration and relevant

	port sections of the online documentation.

	***************************************************************************

*/



/*

 * A sample implementation of pvPortMalloc() and vPortFree() that permits

 * allocated blocks to be freed, but does not combine adjacent free blocks

 * into a single larger block.

 *

 * See heap_1.c and heap_3.c for alternative implementations, and the memory

 * management pages of http://www.FreeRTOS.org for more information.

 */

#include <stdlib.h>



#include "FreeRTOS.h"

#include "task.h"



/* Setup the correct byte alignment mask for the defined byte alignment. */

#if portBYTE_ALIGNMENT == 4

	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0003 )

#endif



#if portBYTE_ALIGNMENT == 2

	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0001 )

#endif



#if portBYTE_ALIGNMENT == 1

	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0000 )

#endif



#ifndef heapBYTE_ALIGNMENT_MASK

	#error "Invalid portBYTE_ALIGNMENT definition"

#endif



/* Allocate the memory for the heap.  The struct is used to force byte

alignment without using any non-portable code. */

static struct xRTOS_HEAP

{

	unsigned portLONG ulDummy;

	unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];

} xHeap;



/* Define the linked list structure.  This is used to link free blocks in order

of their size. */

typedef struct A_BLOCK_LINK

{

	struct A_BLOCK_LINK *pxNextFreeBlock;	/*<< The next free block in the list. */

	size_t xBlockSize;						/*<< The size of the free block. */

} xBlockLink;





static const unsigned portSHORT  heapSTRUCT_SIZE	= ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );

#define heapMINIMUM_BLOCK_SIZE	( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )



/* Create a couple of list links to mark the start and end of the list. */

static xBlockLink xStart, xEnd;



/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */



/*

 * Insert a block into the list of free blocks - which is ordered by size of

 * the block.  Small blocks at the start of the list and large blocks at the end

 * of the list.

 */

#define prvInsertBlockIntoFreeList( pxBlockToInsert )								\

{																					\

xBlockLink *pxIterator;																\

size_t xBlockSize;																	\

																					\

	xBlockSize = pxBlockToInsert->xBlockSize;										\

																					\

	/* Iterate through the list until a block is found that has a larger size */	\

	/* than the block we are inserting. */											\

	for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock )	\

	{																				\

		/* There is nothing to do here - just iterate to the correct position. */	\

	}																				\

																					\

	/* Update the list to include the block being inserted in the correct */		\

	/* position. */																	\

	pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;					\

	pxIterator->pxNextFreeBlock = pxBlockToInsert;									\

}

/*-----------------------------------------------------------*/



#define prvHeapInit()																\

{																					\

xBlockLink *pxFirstFreeBlock;														\

																					\

	/* xStart is used to hold a pointer to the first item in the list of free */	\

	/* blocks.  The void cast is used to prevent compiler warnings. */				\

	xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap;								\

	xStart.xBlockSize = ( size_t ) 0;												\

																					\

	/* xEnd is used to mark the end of the list of free blocks. */					\

	xEnd.xBlockSize = configTOTAL_HEAP_SIZE;										\

	xEnd.pxNextFreeBlock = NULL;													\

																					\

	/* To start with there is a single free block that is sized to take up the		\

	entire heap space. */															\

	pxFirstFreeBlock = ( void * ) xHeap.ucHeap;										\

	pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE;							\

	pxFirstFreeBlock->pxNextFreeBlock = &xEnd;										\

}

/*-----------------------------------------------------------*/



void *pvPortMalloc( size_t xWantedSize )

{

xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink;

static portBASE_TYPE 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 xBlockLink

		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 & heapBYTE_ALIGNMENT_MASK )

			{

				/* Byte alignment required. */

				xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );

			}

		}



		if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_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 ) )

			{

				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 xBlockLink structure

				at its start. */

				pvReturn = ( void * ) ( ( ( unsigned portCHAR * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );



				/* This block is being returned for use so must be taken our 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 * ) ( ( ( unsigned portCHAR * ) 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 ) );

				}

			}

		}

	}

	xTaskResumeAll();



	return pvReturn;

}

/*-----------------------------------------------------------*/



void vPortFree( void *pv )

{

unsigned portCHAR *puc = ( unsigned portCHAR * ) pv;

xBlockLink *pxLink;



	if( pv )

	{

		/* The memory being freed will have an xBlockLink structure immediately

		before it. */

		puc -= heapSTRUCT_SIZE;



		/* This casting is to keep the compiler from issuing warnings. */

		pxLink = ( void * ) puc;



		vTaskSuspendAll();

		{				

			/* Add this block to the list of free blocks. */

			prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) );

		}

		xTaskResumeAll();

	}

}

/*-----------------------------------------------------------*/



?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
五月天亚洲婷婷| 4438成人网| 中文字幕欧美日韩一区| 国产a久久麻豆| 国产精品久久久久久久久免费相片| 国产成人免费视| 国产精品福利av| 在线视频欧美精品| 日韩精品乱码免费| 久久久青草青青国产亚洲免观| 国产精品中文有码| 中文字幕日本乱码精品影院| 在线欧美日韩精品| 免费成人在线观看视频| 国产亚洲欧美激情| 色综合久久中文字幕综合网| 一区二区三区成人| 日韩欧美一区二区免费| 国产一区二区精品在线观看| 1024精品合集| 日韩一区二区三区在线视频| 成人免费看片app下载| 亚洲综合成人在线| 久久久久国产一区二区三区四区 | 欧美系列在线观看| 老司机免费视频一区二区| 国产肉丝袜一区二区| 一本到三区不卡视频| 麻豆精品视频在线观看视频| 国产精品人成在线观看免费| 欧美日韩成人综合在线一区二区 | 久久精品一区二区三区不卡牛牛| 99国产精品一区| 日韩精品91亚洲二区在线观看| 国产欧美一区二区三区鸳鸯浴 | 欧美性一二三区| 国内精品伊人久久久久影院对白| 亚洲精品成人精品456| 精品成人一区二区| 欧美色图天堂网| 国产成人免费视频一区| 日韩av中文在线观看| 亚洲视频在线一区二区| 久久婷婷色综合| 欧美三级电影一区| 99精品视频中文字幕| 国产在线一区二区综合免费视频| 亚洲福利电影网| 中文字幕一区二区三中文字幕| 日韩一级片网站| 欧美日韩免费一区二区三区| 成人黄色软件下载| 国产麻豆成人精品| 麻豆精品在线看| 日韩在线观看一区二区| 一区二区国产视频| 亚洲欧美日韩小说| 中文字幕精品在线不卡| 日韩精品专区在线影院观看| 欧美精品v国产精品v日韩精品| 色婷婷综合久久久久中文| 福利电影一区二区三区| 国内国产精品久久| 六月丁香婷婷色狠狠久久| 午夜精品久久久久久久久久| 伊人性伊人情综合网| 国产精品福利一区| 国产精品久久久久精k8| 国产精品麻豆视频| 国产欧美日韩三区| 国产午夜精品一区二区三区视频| 精品国产自在久精品国产| 这里只有精品电影| 欧美日韩日本视频| 欧美精品自拍偷拍| 欧美一区二区成人| 日韩欧美一卡二卡| 久久亚洲一区二区三区四区| 精品国产乱码久久久久久图片| 日韩三级在线观看| 精品国产一区二区三区忘忧草| 欧美va亚洲va香蕉在线| 欧美精品一区二区三区在线播放| 精品欧美一区二区久久| 久久女同互慰一区二区三区| 久久综合久久综合九色| 国产三级欧美三级日产三级99| 久久久久久久网| 国产精品乱码人人做人人爱 | 日韩一区二区三区四区五区六区| 91精品国产色综合久久不卡蜜臀| 4438x成人网最大色成网站| 欧美一级日韩不卡播放免费| 日韩免费视频一区二区| 精品国产伦一区二区三区观看体验| 精品国产伦一区二区三区观看方式 | 亚洲香肠在线观看| 日韩福利电影在线观看| 久久电影网站中文字幕| 国产麻豆日韩欧美久久| 91色|porny| 欧美精品1区2区3区| 精品精品欲导航| 国产精品你懂的| 亚洲成人手机在线| 国产主播一区二区| 99麻豆久久久国产精品免费优播| 在线观看国产一区二区| 日韩欧美电影一二三| 国产精品欧美一区喷水| 亚洲一区二区在线播放相泽| 久久99最新地址| aaa国产一区| 91麻豆精品国产| 国产日本一区二区| 亚洲国产婷婷综合在线精品| 蜜臂av日日欢夜夜爽一区| 国产91色综合久久免费分享| 精品视频一区二区不卡| 久久日韩精品一区二区五区| 亚洲品质自拍视频网站| 日韩av中文字幕一区二区三区 | 看电影不卡的网站| 99re视频精品| 日韩精品一区二区三区老鸭窝| 国产精品福利一区二区三区| 日韩高清中文字幕一区| k8久久久一区二区三区| 日韩一区二区电影| 亚洲免费资源在线播放| 韩国成人福利片在线播放| 91成人免费在线| 欧美激情中文字幕| 日本最新不卡在线| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 99久久精品国产观看| 日韩欧美不卡在线观看视频| 亚洲日本韩国一区| 国产成人精品影视| 欧美一区二区在线看| 91免费精品国自产拍在线不卡| 日韩精品一区二区在线观看| 亚洲视频图片小说| 国产成人av电影在线观看| 777精品伊人久久久久大香线蕉| 欧美国产日韩a欧美在线观看 | 亚洲欧洲制服丝袜| 国产精品123区| 欧美成人午夜电影| 香蕉成人啪国产精品视频综合网| 波多野结衣中文一区| 久久这里只有精品首页| 日韩精品乱码免费| 欧美裸体一区二区三区| 亚洲狼人国产精品| 91美女视频网站| 国产精品第五页| 成人免费高清在线| 国产日产欧美精品一区二区三区| 美女网站在线免费欧美精品| 欧美肥大bbwbbw高潮| 亚洲福利视频导航| 欧美性猛交xxxx黑人交| 一区二区三区在线观看国产| 91丨九色丨国产丨porny| 亚洲视频综合在线| 99久久精品国产毛片| 自拍视频在线观看一区二区| 国产成人免费视频网站高清观看视频| 精品国产一二三区| 国产一区二区在线免费观看| 精品区一区二区| 国产一区二区毛片| 国产精品污www在线观看| 国产老肥熟一区二区三区| 久久久亚洲精品石原莉奈| 久久er99热精品一区二区| 久久久一区二区三区| 粗大黑人巨茎大战欧美成人| 国产精品人妖ts系列视频| www.成人在线| 亚洲美女一区二区三区| 欧美色欧美亚洲另类二区| 亚洲第一狼人社区| 日韩一区二区影院| 国产精品自拍av| 亚洲丝袜制服诱惑| 欧美视频在线一区二区三区| 亚洲成人免费av| 久久综合狠狠综合久久激情| 国产成人综合视频| 成人欧美一区二区三区| 欧美亚洲另类激情小说| 日韩综合小视频| 久久久久久久久伊人| 99久久精品免费精品国产| 午夜伦欧美伦电影理论片| 欧美大胆人体bbbb| av中文字幕亚洲| 午夜精品爽啪视频|