Ignore:
Timestamp:
Oct 14, 1999, 3:19:22 AM (26 years ago)
Author:
bird
Message:

Changes during Pe2Lx rewrite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/misc/malloc.c

    r847 r1271  
    1 /* $Id: malloc.c,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: malloc.c,v 1.2 1999-10-14 01:19:21 bird Exp $
    22 *
    33 * Heap.
     
    1919
    2020#define SIGNATURE 0xBEEFFEEB
    21 #define CB_HDR (sizeof(MEMBLOCK) - 1) /* size of MEMBLOCK header (in bytes) */
     21/*#define CB_HDR (sizeof(MEMBLOCK) - 1) /* size of MEMBLOCK header (in bytes) */
     22#define CB_HDR (int)&(((PMEMBLOCK)0)->achUserData[0])
    2223#define PNEXT_BLOCK(a) ((PMEMBLOCK)((unsigned)(a) + CB_HDR + (a)->cbSize))
    2324
     
    2526#define INCL_DOSERRORS
    2627#ifdef RING0
    27 #define INCL_NOAPI
     28    #define INCL_NOAPI
    2829#else
    29 #define INCL_DOSMEMMGR
     30    #define INCL_DOSMEMMGR
    3031#endif
     32
    3133
    3234/******************************************************************************
     
    3436******************************************************************************/
    3537#include <os2.h>
    36 
     38#ifdef RING0
     39    #include "dev32hlp.h"
     40    #include "asmutils.h"
     41#else
     42    #include <builtin.h>
     43    #define Int3() __interrupt(3)
     44#endif
    3745#include "log.h"
    38 #include "dev32hlp.h"
    39 #include "asmutils.h"
    4046#include "malloc.h"
    41 #include "memory.h"
     47#include <memory.h>
    4248
    4349
     
    4551*  Structs and Typedefs
    4652******************************************************************************/
     53#pragma pack(1)
    4754typedef struct _MEMBLOCK /* MB */
    4855{
     
    5461   unsigned char     achUserData[1];
    5562} MEMBLOCK, *PMEMBLOCK;
    56 
     63#pragma pack()
    5764
    5865/******************************************************************************
    5966*  Global data
    6067******************************************************************************/
     68/*#pragma info(nogen, nouni, noext)*/
    6169static PMEMBLOCK   pUsed;         /* pointer to the used memblock chain. */
    6270static PMEMBLOCK   pFree;         /* pointer to the free memblock chain. */
    6371static unsigned    cbFree;        /* bytes of free user memory in the heap.*/
    64 unsigned           _uHeapMinPtr; /* heap pointers are greater or equal to this.*/
    65 unsigned           _uHeapMaxPtr; /* heap pointers are less than this. */
     72unsigned           _uHeapMinPtr;  /* heap pointers are greater or equal to this.*/
     73unsigned           _uHeapMaxPtr;  /* heap pointers are less than this. */
     74#ifndef RING0
     75    char           fInited;       /* init flag */
     76#endif
    6677
    6778/******************************************************************************
     
    277288    pUsed = NULL;
    278289
    279     #if RING0
     290    #ifdef RING0
    280291        pFree = D32Hlp_VMAlloc(VMDHA_SWAP | VMDHA_USEHIGHMEM, cbSize, ~0UL);
    281292    #else
    282         if (DosAllocMem(&pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0)
    283             pFree = NULL
     293        if (DosAllocMem((void*)&pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0)
     294            pFree = NULL;
    284295    #endif
    285296    if (pFree == NULL)
     
    308319            return -2;
    309320        }
     321    #endif
     322    #ifdef RING3
     323        fInited = TRUE;
    310324    #endif
    311325    return 0;
     
    323337{
    324338    void *pvRet = NULL;
     339
    325340    #ifdef DEBUG_ALLOC
    326341        if (!_heap_check())
     
    384399            pvRet = malloc(cbNew);
    385400            if (pvRet != NULL)
     401            {
    386402                memcpy(pvRet, pv, pMemblock->cbSize);
    387         }
    388 
     403                free(pv);
     404            }
     405        }
     406        return pvRet;
    389407    }
    390408    return NULL;
     
    598616
    599617
     618#if !defined(RING0) && defined(__IBMC__)
     619
     620/**
     621 * Initialize Memory Functions
     622 * Called from _exeentry.
     623 */
     624int _rmem_init(void)
     625{
     626    int rc = heapInit(HEAP_SIZE);
     627    return rc;
     628}
     629
     630/**
     631 * Initialize Memory Functions
     632 * Called from _exeentry.
     633 */
     634int _rmem_term(void)
     635{
     636    return 0;
     637}
     638
     639#endif
Note: See TracChangeset for help on using the changeset viewer.