cxbfget.c

来自「上传一个带源代码的嵌入式实时多任务操作系统CMX」· C语言 代码 · 共 61 行

C
61
字号
/*********************************************************

Copyright (c) CMX Company. 1999. All rights reserved

*********************************************************/
/* version 5.30 */

#define CMXMODULE 1

#include <cxfuncs.h>	/* get cmx include header file */
#include <cxextern.h>	/* get cmx include header file */

#if (defined(CMXTRACKER) || defined(WINTRACKER))
#include <cmxtrack.h>	/* get cmx include header file */
#endif

/****************************************************************
 this function passes a pointer of a free fixed memory block
 if one is available, to the caller.
****************************************************************/
byte K_Mem_FB_Get(void *part,byte **addr)
{
	byte *link;	/* scratch pointer */

	K_I_Disable_Sched();	/* prevent interruption by another task */
	link = *(byte **) part;	/* get head of free memory block */
	if (link != NULL)	/*  exhausted if link is null */
		{
		*(byte **) part = *(byte **) link; /* update head */
		*addr = link;	/* load address of memory block to user pointer */
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
#if (defined(WINTRACKER))
			cmxtracker_in1(CXBFGET_K_OK);
#else
			cmxtracker_in5(CXBFGET_K_OK,0,link);
#endif
			}
#endif
		K_I_Func_Return();	/* release task block. */
		return(K_OK);	/* return good status. */
		}
	else
		{
#if (defined(CMXTRACKER) || defined(WINTRACKER))
		if (CMXTRACKER_ON)
			{
#if (defined(WINTRACKER))
			cmxtracker_in1(CXBFGET_K_ERROR);
#else
			cmxtracker_in5(CXBFGET_K_ERROR,0,part);
#endif
			}
#endif
		K_I_Func_Return();	/* release task block. */
		return(K_ERROR);		/* Error: no more memory blocks available */
		}
}	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?