Ignore:
Timestamp:
Jun 6, 1999, 2:25:49 PM (26 years ago)
Author:
cbratschi
Message:

hiho

File:
1 edited

Legend:

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

    r20 r37  
    1 /* $Id: heap.cpp,v 1.4 1999-05-31 23:17:17 phaller Exp $ */
     1/* $Id: heap.cpp,v 1.5 1999-06-06 12:25:49 cbratschi Exp $ */
    22
    33/*
     
    7171  curheap = new OS2Heap(hHeap, flOptions, dwInitialSize, dwMaximumSize);
    7272  if(curheap == NULL) {
    73         O32_HeapDestroy(hHeap);
     73        O32_HeapDestroy(hHeap);
    7474        return(NULL);
    7575  }
    7676  if(curheap->getHeapHandle() == NULL) {
    77         O32_HeapDestroy(hHeap);
     77        O32_HeapDestroy(hHeap);
    7878        delete curheap;
    7979        return(NULL);
     
    9898/* PH: Though "HeapSize" is a reserved word for the linker, ILINK can be
    9999   tricked by placing the word HEAPSIZE in quotes. It then exports it properly
    100    to the target DLL. 
     100   to the target DLL.
    101101 */
    102102DWORD WIN32API HeapSize(HANDLE hHeap, DWORD arg2, PVOID  arg3)
     
    154154    //SvL: Only one process heap per process
    155155    if(processheap == NULL) {
    156         //TODO: I haven't thought real hard about this.  I added it just to make "hdr.exe" happy.
    157         hHeap = O32_HeapCreate(HEAP_GENERATE_EXCEPTIONS, 1, 0x4000);
    158         OS2ProcessHeap = new OS2Heap(hHeap, HEAP_GENERATE_EXCEPTIONS, 0x4000, 0);
    159         if(OS2ProcessHeap == NULL) {
    160                 O32_HeapDestroy(hHeap);
    161                 return(NULL);
    162         }
    163         processheap = hHeap;
     156        //TODO: I haven't thought real hard about this.  I added it just to make "hdr.exe" happy.
     157        hHeap = O32_HeapCreate(HEAP_GENERATE_EXCEPTIONS, 1, 0x4000);
     158        OS2ProcessHeap = new OS2Heap(hHeap, HEAP_GENERATE_EXCEPTIONS, 0x4000, 0);
     159        if(OS2ProcessHeap == NULL) {
     160                O32_HeapDestroy(hHeap);
     161                return(NULL);
     162        }
     163        processheap = hHeap;
    164164    }
    165165    return(processheap);
     
    173173
    174174  if(processheap == NULL) {
    175         if(GetProcessHeap() == NULL)
    176                 return(NULL);
     175        if(GetProcessHeap() == NULL)
     176                return(NULL);
    177177  }
    178178  if(fuFlags & LMEM_ZEROINIT)
     
    209209
    210210    if(OS2ProcessHeap->GetLockCnt((LPVOID)hMem) != 0) {
    211         dprintf(("LocalFree, lock count != 0\n"));
    212         return(hMem);   //TODO: SetLastError
     211        dprintf(("LocalFree, lock count != 0\n"));
     212        return(hMem);   //TODO: SetLastError
    213213    }
    214214    if(OS2ProcessHeap->Free(0, (LPVOID)hMem) == FALSE) {
    215         return(hMem);   //TODO: SetLastError
     215        return(hMem);   //TODO: SetLastError
    216216    }
    217217    return NULL; //success
     
    238238HLOCAL WIN32API LocalReAlloc(HLOCAL hMem, DWORD cbBytes, UINT fuFlags)
    239239{
    240  LPVOID lpMem;
     240 HLOCAL lpMem;
    241241
    242242    dprintf(("KERNEL32: LocalReAlloc %X %d %X\n", hMem, cbBytes, fuFlags));
    243243    //SvL: 8-8-'98: Notepad bugfix (assumes address is identical when new size < old size)
    244     if(OS2ProcessHeap->Size(0, (LPVOID)hMem) > cbBytes)
    245         return hMem;
    246 
    247     lpMem = (LPVOID)O32_LocalAlloc(fuFlags, cbBytes);
    248     memcpy(lpMem, (LPVOID)hMem, min(cbBytes, OS2ProcessHeap->Size(0, (LPVOID)hMem)));
     244    if(OS2ProcessHeap->Size(0, (LPVOID)hMem) >= cbBytes)
     245    {
     246        dprintf(("KERNEL32:  LocalReAlloc returned %X\n", hMem));
     247        return hMem;
     248    }
     249
     250    lpMem = LocalAlloc(fuFlags, cbBytes);
     251    memcpy((LPVOID)lpMem, (LPVOID)hMem, min(cbBytes, OS2ProcessHeap->Size(0, (LPVOID)hMem)));
    249252    OS2ProcessHeap->Free(0, (LPVOID)hMem);
     253
     254    dprintf(("KERNEL32:  LocalReAlloc returned %X\n", lpMem));
    250255    return((HLOCAL)lpMem);
    251256}
Note: See TracChangeset for help on using the changeset viewer.