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

📄 stdlib.c

📁 gumstiz u-boot loader in linux
💻 C
字号:
/******************************************************************************                   SciTech OS Portability Manager Library**  ========================================================================**    The contents of this file are subject to the SciTech MGL Public*    License Version 1.0 (the "License"); you may not use this file*    except in compliance with the License. You may obtain a copy of*    the License at http://www.scitechsoft.com/mgl-license.txt**    Software distributed under the License is distributed on an*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*    implied. See the License for the specific language governing*    rights and limitations under the License.**    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.**    The Initial Developer of the Original Code is SciTech Software, Inc.*    All Rights Reserved.**  ========================================================================** Language:     ANSI C* Environment:  32-bit Windows NT driver** Description:  C library compatible stdlib.h functions for use within a*               Windows NT driver.*****************************************************************************/#include "pmapi.h"#include "oshdr.h"/*------------------------ Main Code Implementation -----------------------*//****************************************************************************REMARKS:PM_malloc override function for Nucleus drivers loaded in NT drivers's.****************************************************************************/void * malloc(    size_t size){    return PM_mallocShared(size);}/****************************************************************************REMARKS:calloc library function for Nucleus drivers loaded in NT drivers's.****************************************************************************/void * calloc(    size_t nelem,    size_t size){    void *p = PM_mallocShared(nelem * size);    if (p)	memset(p,0,nelem * size);    return p;}/****************************************************************************REMARKS:PM_realloc override function for Nucleus drivers loaded in VxD's.****************************************************************************/void * realloc(    void *ptr,    size_t size){    void *p = PM_mallocShared(size);    if (p) {	memcpy(p,ptr,size);	PM_freeShared(ptr);	}    return p;}/****************************************************************************REMARKS:PM_free override function for Nucleus drivers loaded in VxD's.****************************************************************************/void free(    void *p){    PM_freeShared(p);}/****************************************************************************PARAMETERS:cstr    - C style ANSI string to convertRETURNS:Pointer to the UniCode string structure or NULL on failure to allocate memoryREMARKS:Converts a C style string to a UniCode string structure that can be passeddirectly to NT kernel functions.****************************************************************************/UNICODE_STRING *_PM_CStringToUnicodeString(    const char *cstr){    int             length;    ANSI_STRING     ansiStr;    UNICODE_STRING  *uniStr;    /* Allocate memory for the string structure */    if ((uniStr = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING))) == NULL)	return NULL;    /* Allocate memory for the wide string itself */    length = (strlen(cstr) * sizeof(WCHAR)) + sizeof(WCHAR);    if ((uniStr->Buffer = ExAllocatePool(NonPagedPool, length)) == NULL) {	ExFreePool(uniStr);	return NULL;	}    RtlZeroMemory(uniStr->Buffer, length);    uniStr->Length = 0;    uniStr->MaximumLength = (USHORT)length;    /* Convert filename string to ansi string and then to UniCode string */    RtlInitAnsiString(&ansiStr, cstr);    RtlAnsiStringToUnicodeString(uniStr, &ansiStr, FALSE);    return uniStr;}/****************************************************************************PARAMETERS:uniStr  - UniCode string structure to freeREMARKS:Frees a string allocated by the above _PM_CStringToUnicodeString function.****************************************************************************/void _PM_FreeUnicodeString(    UNICODE_STRING *uniStr){    if (uniStr) {	ExFreePool(uniStr->Buffer);	ExFreePool(uniStr);	}}

⌨️ 快捷键说明

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