ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

malloc.c
Go to the documentation of this file.
00001 /* $Id: malloc.c 37763 2008-11-30 11:42:05Z sginsberg $
00002  */
00003 /*
00004  * COPYRIGHT:   None
00005  * LICENSE:     Public domain
00006  * PROJECT:     ReactOS system libraries
00007  * FILE:        reactos/lib/psapi/misc/malloc.c
00008  * PURPOSE:     Memory allocator for PSAPI
00009  * PROGRAMMER:  KJK::Hyperion <noog@libero.it>
00010  * UPDATE HISTORY:
00011  *              10/06/2002: Created
00012  *              12/02/2003: malloc and free renamed to PsaiMalloc and PsaiFree,
00013  *                          for better reusability
00014  */
00015 
00016 #include "precomp.h"
00017 
00018 #define NDEBUG
00019 #include <debug.h>
00020 
00021 PVOID
00022 WINAPI
00023 MemAlloc(IN HANDLE Heap,
00024          IN PVOID Ptr,
00025          IN ULONG Size)
00026 {
00027   PVOID pBuf = NULL;
00028 
00029   if(Size == 0 && Ptr == NULL)
00030   {
00031     return NULL;
00032   }
00033 
00034   if(Heap == NULL)
00035   {
00036     Heap = NtCurrentPeb()->ProcessHeap;
00037   }
00038 
00039   if(Size > 0)
00040   {
00041     if(Ptr == NULL)
00042       /* malloc */
00043       pBuf = RtlAllocateHeap(Heap, 0, Size);
00044     else
00045       /* realloc */
00046       pBuf = RtlReAllocateHeap(Heap, 0, Ptr, Size);
00047   }
00048   else
00049     /* free */
00050     RtlFreeHeap(Heap, 0, Ptr);
00051 
00052   return pBuf;
00053 }
00054 
00055 void *PsaiMalloc(SIZE_T size)
00056 {
00057  return MemAlloc(NULL, NULL, size);
00058 }
00059 
00060 void *PsaiRealloc(void *ptr, SIZE_T size)
00061 {
00062  return MemAlloc(NULL, ptr, size);
00063 }
00064 
00065 void PsaiFree(void *ptr)
00066 {
00067  MemAlloc(NULL, ptr, 0);
00068 }
00069 
00070 /* EOF */
00071 

Generated on Sat May 26 2012 04:24:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.