Ignore:
Timestamp:
Aug 3, 1999, 7:38:59 PM (26 years ago)
Author:
phaller
Message:

Fix: OS2Heap::ReAlloc() fixes for zero allocation and reallocation with same size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/os2heap.cpp

    r120 r404  
    1 /* $Id: os2heap.cpp,v 1.4 1999-06-19 10:54:42 sandervl Exp $ */
     1/* $Id: os2heap.cpp,v 1.5 1999-08-03 17:38:59 phaller Exp $ */
    22
    33/*
     
    216216//******************************************************************************
    217217//******************************************************************************
     218DWORD OS2Heap::Size(DWORD dwFlags, PVOID lpMem)
     219{
     220//  dprintf(("OS2Heap::Size, %X\n", lpMem));
     221  if(lpMem == NULL)
     222    return(0);
     223
     224  return(_msize((char *)lpMem - sizeof(HEAPELEM)) - HEAP_OVERHEAD);
     225}
     226//******************************************************************************
     227//******************************************************************************
    218228LPVOID OS2Heap::ReAlloc(DWORD dwFlags, LPVOID lpMem, DWORD dwBytes)
    219229{
    220  LPVOID lpNewMem;
    221  int    i;
     230  LPVOID lpNewMem;
     231  int    i;
     232
     233  if (dwBytes == 0) return NULL;         // intercept stupid parameters
     234  if (lpMem == 0)   return NULL;
     235
     236  if (Size(0,lpMem) == dwBytes) return lpMem; // if reallocation with same size
     237                                                // don't do anything
    222238
    223239//  dprintf(("OS2Heap::ReAlloc %X %X %d\n", dwFlags, lpMem, dwBytes));
     
    264280//******************************************************************************
    265281//******************************************************************************
    266 DWORD OS2Heap::Size(DWORD dwFlags, PVOID lpMem)
    267 {
    268 //  dprintf(("OS2Heap::Size, %X\n", lpMem));
    269   if(lpMem == NULL)
    270     return(0);
    271 
    272   return(_msize((char *)lpMem - sizeof(HEAPELEM)) - HEAP_OVERHEAD);
    273 }
    274 //******************************************************************************
    275 //******************************************************************************
    276282DWORD OS2Heap::Compact(DWORD dwFlags)
    277283{
Note: See TracChangeset for help on using the changeset viewer.