⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memfile.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
字号:
/***************************************************************************
 * Name        : memfile.c
 * Title       : MBX WinCE driver
 * Author(s)   : Imagination Technologies
 * Created	   : 8th December 2003
 *
 * Copyright   : 2003 by Imagination Technologies. All rights reserved.
 *             : No part of this software, either material or conceptual 
 *             : may be copied or distributed, transmitted, transcribed,
 *             : stored in a retrieval system or translated into any 
 *             : human or computer language in any form by any means,
 *             : electronic, mechanical, manual or other-wise, or 
 *             : disclosed to third parties without the express written
 *             : permission of Imagination Technologies Limited, Unit 8,
 *             : HomePark Industrial Estate, King's Langley, Hertfordshire,
 *             : WD4 8LZ, U.K.
 *
 * Description : MBX WinCE driver
 *
 * Platform    : WinCE
 *
 * Modifications:-
 * $Log: memfile.c $
 *
 ****************************************************************************/

#include <windows.h>

#include "img_types.h"
#include "memfile.h"

#if HW_VERIFY

IMG_PBYTE  l_pbyBuffer = NULL;
IMG_UINT32 l_ui32Index = 0;
IMG_UINT32 l_ui32BufferSize = 0;
IMG_UINT32 l_ui32Increments = 0;


IMG_BOOL memFileOpen(IMG_UINT32 ui32InitSize, IMG_UINT32 ui32Increments)
{
	l_ui32Index = 0;
	l_ui32Increments = ui32Increments;

	if (l_pbyBuffer == NULL)
	{
		l_pbyBuffer = (IMG_PBYTE)malloc (ui32InitSize);
	}
	else if (l_ui32BufferSize < ui32InitSize)
	{
		l_pbyBuffer = (IMG_PBYTE)realloc(l_pbyBuffer, ui32InitSize);
	}
	else
	{
		return (IMG_TRUE);
	}

	l_ui32BufferSize = ui32InitSize;

	return ((IMG_BOOL)(l_pbyBuffer != NULL));
}


IMG_BOOL memFileSaveIn ( HANDLE hFile)
{
	IMG_BOOL	bResult;
	IMG_UINT32	ui32BytesWritten;

	bResult = WriteFile ( hFile, l_pbyBuffer, l_ui32Index, &ui32BytesWritten, NULL);

	l_ui32Index = 0;

	CloseHandle (hFile);

	return (bResult);
}


IMG_BOOL memFileWrite2DataFile ( PBYTE pbyData, IMG_UINT32 ui32BytesToWrite )
{
	if (l_pbyBuffer)
	{
		if (l_ui32Index + ui32BytesToWrite >= l_ui32BufferSize)
		{
			l_ui32BufferSize += l_ui32Increments;
			l_pbyBuffer = (PBYTE)realloc(l_pbyBuffer, l_ui32BufferSize);
		}

		if (l_pbyBuffer)
		{
			memcpy( &l_pbyBuffer[l_ui32Index], pbyData, ui32BytesToWrite);
			l_ui32Index += ui32BytesToWrite;

			return (IMG_TRUE);
		}
	}

	return (IMG_FALSE);
}


IMG_BOOL memFileClose()
{
	l_ui32Index = 0;

	if (l_pbyBuffer)
	{
		free (l_pbyBuffer);

		l_pbyBuffer = NULL;
	}

	return (IMG_TRUE);
}

#endif /* HW_VERIFY */


/********************************** end of file ******************************/

⌨️ 快捷键说明

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