]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.c
OK i think the borland C version and watcom version behave the same way! ^^
[16.git] / src / lib / 16_mm.c
index 9486e2e55e008d1abcdd0f3ebc8a36d0cb3074b9..3312167239fd0e70b6c7c72a7430596e43a1e5e8 100644 (file)
@@ -120,13 +120,24 @@ boolean MML_CheckForEMS(void)
                //
                mov     emmcfems,1
                jmp End
+#ifdef __BORLANDC__
+       }
+#endif
                error:
+#ifdef __BORLANDC__
+       __asm {
+#endif
                //
                // EMS is bad
                //
                mov     emmcfems,0
+#ifdef __BORLANDC__
+       }
+#endif
                End:
+#ifdef __WATCOMC__
        }
+#endif
        return(emmcfems);
 }
 
@@ -150,8 +161,7 @@ byte MML_SetupEMS(mminfo_t *mm)
        unsigned        totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
        totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0;
 
-       __asm
-               {
+       __asm {
                mov     ah,EMS_STATUS
                int     EMS_INT                                         // make sure EMS hardware is present
                or      ah,ah
@@ -187,13 +197,23 @@ byte MML_SetupEMS(mminfo_t *mm)
                jle     getpages
                mov     bx,[freeEMSpages]
                jmp     getpages
-
-low:
+#ifdef __BORLANDC__
+       }
+#endif
+       low:
+#ifdef __BORLANDC__
+       __asm {
+#endif
                cmp     bx,4
                jle     getpages                                        // there is only 1,2,3,or 4 pages
                mov     bx,4                                            // we can't use more than 4 pages
-
-getpages:
+#ifdef __BORLANDC__
+       }
+#endif
+       getpages:
+#ifdef __BORLANDC__
+       __asm {
+#endif
                mov     [EMSpagesmapped],bx
                mov     ah,EMS_ALLOCPAGES                       // allocate up to 64k of EMS
                int     EMS_INT
@@ -201,19 +221,30 @@ getpages:
                jnz     error
                mov     [EMShandle],dx
                jmp End
-error:
+#ifdef __BORLANDC__
+       }
+#endif
+       error:
+#ifdef __BORLANDC__
+       __asm {
+#endif
                mov     err,ah
                mov     errorflag,1
                jmp End
+#ifdef __BORLANDC__
+       }
+#endif
 noEMS:
 End:
+#ifdef __WATCOMC__
        }
+#endif
        if(errorflag==true)
        {
                //err = CPURegs.h.ah;
                strcpy(str,"MM_SetupEMS: EMS error ");
                //itoa(err,str2,16);
-               MM_EMSerr(&str, err);
+               MM_EMSerr(str, err);
                printf("%s\n",str);
                return err;
        }
@@ -242,16 +273,20 @@ void MML_ShutdownEMS(mminfo_t *mm)
 
        if(!EMShandle)
                return;
-       __asm
-       {
+       __asm {
                mov     ah,EMS_FREEPAGES
                mov     dx,[EMShandle]
                int     EMS_INT
                or      ah,ah
                jz      ok
                mov     errorflag,1
+#ifdef __BORLANDC__
+       }
+#endif
                ok:
+#ifdef __WATCOMC__
        }
+#endif
        if(errorflag==true) printf("MML_ShutdownEMS: Error freeing EMS!\n");    //++++ add something
 }
 
@@ -278,8 +313,7 @@ byte MM_MapEMS(mminfo_t *mm, mminfotype *mmi)
 
        for (i=0;i<4/*MAPPAGES*/;i++)
        {
-               __asm
-               {
+               __asm {
                        mov     ah,EMS_MAPPAGE
                        mov     bx,[i]                  // logical page
                        mov     al,bl                   // physical page
@@ -288,11 +322,22 @@ byte MM_MapEMS(mminfo_t *mm, mminfotype *mmi)
                        or      ah,ah
                        jnz     error
                        jmp End
+#ifdef __BORLANDC__
+               }
+#endif
                        error:
+#ifdef __BORLANDC__
+               __asm {
+#endif
                        mov     err,ah
                        mov     errorflag,1
+#ifdef __BORLANDC__
+               }
+#endif
                        End:
+#ifdef __WATCOMC__
                }
+#endif
                if(errorflag==true)
                {
                        //err = CPURegs.h.ah;
@@ -344,8 +389,7 @@ byte MM_MapXEMS(mminfo_t *mm, mminfotype *mmi)
 
        for (i=0;i<MAPPAGES;i++)
        {
-               __asm
-               {
+               __asm {
                        mov     ah,EMS_MAPXPAGE
                        mov     cx,[i]                  // logical page
                        mov     al,bl                   // physical page
@@ -354,18 +398,29 @@ byte MM_MapXEMS(mminfo_t *mm, mminfotype *mmi)
                        or      ah,ah
                        jnz     error
                        jmp End
+#ifdef __BORLANDC__
+               }
+#endif
                        error:
+#ifdef __BORLANDC__
+               __asm {
+#endif
                        mov     err,ah
                        mov     errorflag,1
+#ifdef __BORLANDC__
+               }
+#endif
                        End:
+#ifdef __WATCOMC__
                }
+#endif
                if(errorflag==true)
                {
                        //err = CPURegs.h.ah;
                        //strcpy(str,"MM_MapXEMS: EMS error 0x");
                        strcpy(str,"MM_MapXEMS: EMS error ");
                        //itoa(err,str2,16);
-                       MM_EMSerr(&str, err);
+                       MM_EMSerr(str, err);
                        printf("%s\n",str);
                        //printf("%s%x\n",str, err);
                        //printf("FACK! %x\n", err);
@@ -393,15 +448,19 @@ boolean MML_CheckForXMS(mminfo_t *mm)
        boolean errorflag=false;
        mm->numUMBs = 0;
 
-       __asm
-       {
+       __asm {
                mov     ax,0x4300
                int     0x2f                            // query status of installed diver
                cmp     al,0x80
                je      good
                mov     errorflag,1
+#ifdef __BORLANDC__
+       }
+#endif
                good:
+#ifdef __WATCOMC__
        }
+#endif
        if(errorflag==true) return false;
        else return true;
 }
@@ -422,8 +481,7 @@ void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi)
        unsigned        base,size;
 
 getmemory:
-       __asm
-       {
+       __asm {
                mov     ax,0x4310
                int     0x2f
                mov     [WORD PTR XMSaddr],bx
@@ -443,12 +501,22 @@ getmemory:
                call    [DWORD PTR XMSaddr]             // DX holds largest available UMB
                or      ax,ax
                jz      done                                            // another error...
-
-gotone:
+#ifdef __BORLANDC__
+       }
+#endif
+               gotone:
+#ifdef __BORLANDC__
+       __asm {
+#endif
                mov     [base],bx
                mov     [size],dx
-done:
+#ifdef __BORLANDC__
+       }
+#endif
+               done:
+#ifdef __WATCOMC__
        }
+#endif
        printf("base=%u ", base); printf("size=%u\n", size);
        MML_UseSpace(base,size, mm);
        mmi->XMSmem += size*16;
@@ -475,8 +543,7 @@ void MML_ShutdownXMS(mminfo_t *mm)
        for (i=0;i<mm->numUMBs;i++)
        {
                base = mm->UMBbase[i];
-               __asm
-               {
+               __asm {
                        mov     ah,XMS_FREEUMB
                        mov     dx,[base]
                        call    [DWORD PTR XMSaddr]
@@ -521,7 +588,7 @@ void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
        if(seglength>0xffffu)
        {
 //             segm=seglength/0x4000u;
-               segm=seglength/0xffffu;
+               segm=(word)seglength/0xffffu;
        }
        else segm=1;
 
@@ -565,7 +632,7 @@ printf("seglen=%lu\n", seglength);
        if(segstart == scan->start)
        {
                last->next = scan->next;                        // unlink block
-               MM_FreeBlock(scan, mm);
+               FREEBLOCK(scan);
                scan = last;
        }
        else
@@ -575,7 +642,8 @@ printf("seglen=%lu\n", seglength);
 
        if(extra > 0)
        {
-               MM_GetNewBlock(mm);
+               //MM_GetNewBlock(mm);
+               GETNEWBLOCK;
                mm->mmnew->next = scan->next;
                scan->next = mm->mmnew;
                mm->mmnew->start = segstart+seglength;
@@ -643,6 +711,7 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
 
        mm->mmstarted = true;
        mm->bombonerror = true;
+       mm->endid=0;
 
 //
 // set up the linked list (everything in the free list;
@@ -660,7 +729,8 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
 // locked block of all memory until we punch out free space
 //
        //printf("              newblock making!\n");
-       MM_GetNewBlock(mm);
+       //MM_GetNewBlock(mm);
+       GETNEWBLOCK;
        mm->mmhead = mm->mmnew;                         // this will allways be the first node
        mm->mmnew->start = 0;
        mm->mmnew->length = 0xffff;
@@ -671,28 +741,36 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
 //
 // get all available near conventional memory segments
 //
-//---- length=coreleft();
-       printf("                nearheap making!\n");
+//     printf("                nearheap making!\n");
+#ifdef __WATCOMC__
        _nheapgrow();
-       length=(dword)_coreleft();//(dword)_memmax();//(dword)GetFreeSize();
+       length=(dword)_memavl();//(dword)GetFreeSize();
        start = (void huge *)(mm->nearheap = _nmalloc(length));
+#endif
+#ifdef __BORLANDC__
+       length=coreleft();
+       start = (void huge *)(mm->nearheap = malloc(length));
+#endif
        length -= 16-(FP_OFF(start)&15);
        length -= SAVENEARHEAP;
        seglength = length / 16;                        // now in paragraphs
        segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
        MML_UseSpace(segstart,seglength, mm);
        mmi->nearheap = length;
-       printf("start=%FP       segstart=%X     seglen=%lu      len=%lu\n", start, segstart, seglength, length);
+       printf("start=%Fp       segstart=%x     seglen=%l       len=%l\n", start, segstart, seglength, length);
        //heapdump();
-       //getch();
 
 //
 // get all available far conventional memory segments
 //
-//---- length=farcoreleft();
-       printf("                farheap making!\n");
+//     printf("                farheap making!\n");
+#ifdef __WATCOMC__
        _fheapgrow();
-       length=(dword)_farcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL;
+       length=(dword)GetFarFreeSize();//0xffffUL*4UL;
+#endif
+#ifdef __BORLANDC__
+       length=farcoreleft();
+#endif
        //start = mm->farheap = halloc(length, 1);
        start = mm->farheap = _fmalloc(length);
        length -= 16-(FP_OFF(start)&15);
@@ -701,59 +779,90 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
        segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
        MML_UseSpace(segstart,seglength, mm);
        mmi->farheap = length;
-       printf("start=%FP       segstart=%X     seglen=%lu      len=%lu\n", start, segstart, seglength, length);
-       heapdump();
+       printf("start=%Fp       segstart=%x     seglen=%l       len=%l\n", start, segstart, seglength, length);
+       //heapdump();
 
        mmi->mainmem = mmi->nearheap + mmi->farheap;
 
-       getch();
+//     getch();
 
 //goto xmsskip;
 
 //
 // detect EMS and allocate up to 64K at page frame
 //
-printf("               EMS1\n");
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("             EMS1\n");
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
        mmi->EMSmem = 0;
-       for(i = 1;i < __argc;i++)
+       for(i = 1;i <
+#ifdef __WATCOMC__
+       __argc
+#endif
+#ifdef __BORLANDC__
+       _argc
+#endif
+       ;i++)
        {
-               if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
+               if(US_CheckParm(
+#ifdef __WATCOMC__
+       __argv[i]
+#endif
+#ifdef __BORLANDC__
+       _argv[i]
+#endif
+                       ,ParmStringsexmm) == 0)
                        goto emsskip;                           // param NOEMS
        }
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
        if(MML_CheckForEMS())
        {
-printf("               EMS2\n");
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("             EMS2\n");
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
                MML_SetupEMS(mm);                                       // allocate space
-printf("               EMS3\n");
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("             EMS3\n");
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
                //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
                MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
-printf("               EMS4\n");
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
+//printf("             EMS4\n");
                //if(mm->EMSVer<0x40)
                        MM_MapEMS(mm, mmi);                                     // map in used pages
                //else
                        //MM_MapXEMS(mm, mmi);                                  // map in used pages
        }
 
+mmi->XMSmem=0;
+goto xmsskip;
+
 //
 // detect XMS and get upper memory blocks
 //
 emsskip:
        mmi->XMSmem = 0;
-       for(i = 1;i < __argc;i++)
+       for(i = 1;i <
+#ifdef __WATCOMC__
+       __argc
+#endif
+#ifdef __BORLANDC__
+       _argc
+#endif
+       ;i++)
        {
-               if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
+               if(US_CheckParm(
+#ifdef __WATCOMC__
+       __argv[i]
+#endif
+#ifdef __BORLANDC__
+       _argv[i]
+#endif
+                       ,ParmStringsexmm) == 0)
                        goto xmsskip;                           // param NOXMS
        }
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
        if(MML_CheckForXMS(mm))
        {
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
-printf("               XMS!\n");
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
+//printf("             XMS!\n");
                MML_SetupXMS(mm, mmi);                                  // allocate as many UMBs as possible
        }
 
@@ -784,7 +893,12 @@ void MM_Shutdown(mminfo_t *mm)
                return;
 
        _ffree(mm->farheap);    printf("                far freed\n");
+#ifdef __WATCOMC__
        _nfree(mm->nearheap);   printf("                near freed\n");
+#endif
+#ifdef __BORLANDC__
+       free(mm->nearheap);     printf("                near freed\n");
+#endif
        if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf("            EMS freed\n"); }
        if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf("          XMS freed\n"); }
 }
@@ -805,17 +919,20 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
 {
        mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next;
        int                     search;
-       unsigned        needed,startseg;
+       dword   needed;
+       word    startseg;
 
        needed = (size+15)/16;          // convert size from bytes to paragraphs
-
-       MM_GetNewBlock(mm);                             // fill in start and next after a spot is found
+printf(".");   //0000
+       //MM_GetNewBlock(mm);
+       GETNEWBLOCK;                            // fill in start and next after a spot is found
        mm->mmnew->length = needed;
        mm->mmnew->useptr = baseptr;
        mm->mmnew->attributes = BASEATTRIBUTES;
-
-       for(search = 0; search<3; search++)
+printf(".");   //0000
+       for(search = 0; search<mm->endid; search++)
        {
+printf("       [case]");       //0000
        //
        // first search:        try to allocate right after the rover, then on up
        // second search:       search from the head pointer up to the rover
@@ -826,16 +943,19 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                switch(search)
                {
                case 0:
+printf("0      ");     //0000
                        lastscan = mm->mmrover;
                        scan = mm->mmrover->next;
                        endscan = NULL;
                        break;
                case 1:
+printf("1      ");     //0000
                        lastscan = mm->mmhead;
                        scan = mm->mmhead->next;
                        endscan = mm->mmrover;
                        break;
                case 2:
+printf("2      ");     //0000
                        MM_SortMem(mm);
                        lastscan = mm->mmhead;
                        scan = mm->mmhead->next;
@@ -843,12 +963,14 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                        break;
                }
 
-               startseg = lastscan->start + lastscan->length;
+               startseg = lastscan->start + (word)lastscan->length;
 
                while(scan != endscan)
                {
+//printf(","); //0000
                        if(scan->start - startseg >= needed)
                        {
+printf(".");   //0000
                        //
                        // got enough space between the end of lastscan and
                        // the start of scan, so throw out anything in the middle
@@ -856,12 +978,14 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                        //
                                purge = lastscan->next;
                                lastscan->next = mm->mmnew;
-                               mm->mmnew->start = *(unsigned *)baseptr = startseg;
+                               mm->mmnew->start = *(word *)baseptr = startseg;
                                mm->mmnew->next = scan;
                                while(purge != scan)
                                {       // free the purgable block
+printf("               freeing block~\n");     //0000
                                        next = purge->next;
-                                       MM_FreeBlock(purge, mm);
+                                       FREEBLOCK(purge);
+                                       //MM_FreeBlock(purge, mm);
                                        purge = next;           // purge another if not at scan
                                }
                                mm->mmrover = mm->mmnew;
@@ -874,19 +998,25 @@ void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
                        if((scan->attributes & LOCKBIT)
                                || !(scan->attributes & PURGEBITS) )
                        {
+printf("       [lock] ");      //0000
+printf("len=%lu ", scan->length);
                                lastscan = scan;
-                               startseg = lastscan->start + lastscan->length;
+                               startseg = lastscan->start + (word)lastscan->length;
                        }
 
-
+printf("\n");
                        scan=scan->next;                // look at next line
                }
        }
 
        if (mm->bombonerror)
        {
+#ifdef __WATCOMC__
+               heapdump();
+#endif
                printf(OUT_OF_MEM_MSG,(size-mmi->nearheap));
                printf("for stability reasons the program will shut down! wwww\n");
+               printf("                endid=%u\n",(mm->endid));
                MM_Shutdown(mm);
                exit(-1);
        }
@@ -930,7 +1060,8 @@ void MM_FreePtr(memptr *baseptr, mminfo_t *mm)
 
        last->next = scan->next;
 
-       MM_FreeBlock(scan, mm);
+       FREEBLOCK(scan);
+       //MM_FreeBlock(scan, mm);
 }
 //==========================================================================
 
@@ -1075,7 +1206,8 @@ void MM_SortMem(mminfo_t *mm)
                        // throw out the purgable block
                        //
                                next = scan->next;
-                               MM_FreeBlock(scan, mm);
+                               FREEBLOCK(scan);
+                               //MM_FreeBlock(scan, mm);
                                last->next = next;
                                scan = next;
                                continue;
@@ -1136,9 +1268,10 @@ void MM_SortMem(mminfo_t *mm)
 void MM_ShowMemory(/*page_t *page, */mminfo_t *mm)
 {
        mmblocktype huge *scan;
-       word color,temp;
+//++++ word color;
+       word temp;
        long    end,owner;
-       word chx,chy;
+//++++ word chx,chy;
        byte    scratch[160],str[16];
 
 //**** VW_SetDefaultColors();
@@ -1153,17 +1286,17 @@ void MM_ShowMemory(/*page_t *page, */mminfo_t *mm)
 
 CA_OpenDebug ();
 
-       chx=0;
-       chy=0;
+//++++ chx=0;
+//++++ chy=0;
 
        while(scan)
        {
-               if(scan->attributes & PURGEBITS)
+/*++++         if(scan->attributes & PURGEBITS)
                        color = 5;              // dark purple = purgable
                else
                        color = 9;              // medium blue = non purgable
                if(scan->attributes & LOCKBIT)
-                       color = 12;             // red = locked
+                       color = 12;             // red = locked*/
                if(scan->start<=end)
                {
                        //printf(");
@@ -1172,8 +1305,8 @@ CA_OpenDebug ();
                        return;
                }
                end = scan->start+scan->length-1;
-               chy = scan->start/320;
-               chx = scan->start%320;
+//++++         chy = scan->start/320;
+//++++         chx = scan->start%320;
                                //modexhlin(page, scan->start, (unsigned)end, chy, color);
                                //for(chx=scan->start;chx+4>=(word)end;chx+=4)
                                //{
@@ -1204,7 +1337,7 @@ CA_OpenDebug ();
 */
 
 //****#if 0
-printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");    //bug!
+//printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");  //bug!
 strcpy(scratch,"Seg:");
 ultoa (scan->start,str,16);
 strcat (scratch,str);
@@ -1245,7 +1378,7 @@ CA_CloseDebug ();
 
 void MM_DumpData(mminfo_t *mm)
 {
-       mmblocktype far *scan,far *best;
+       mmblocktype huge *scan,huge *best;
        long    lowest,oldlowest;
        word    owner;
        byte    lock,purge;
@@ -1543,18 +1676,19 @@ void MM_BombOnError(boolean bomb, mminfo_t *mm)
        mm->bombonerror = bomb;
 }
 
-void MM_GetNewBlock(mminfo_t *mm)
+/*void MM_GetNewBlock(mminfo_t *mm)
 {
        if(!mm->mmfree)
                MML_ClearBlock(mm);
        mm->mmnew=mm->mmfree;
        mm->mmfree=mm->mmfree->next;
-       /*if(!(mm->mmnew=mm->mmfree))
+       if(!(mm->mmnew=mm->mmfree))
        {
-               printf("MM_GETNEWBLOCK: No free blocks!");
+               printf("MM_GETNEWBLOCK: No free blocks!\n");
                return;
        }
-       mm->mmfree=mm->mmfree->next;*/
+       mm->mmfree=mm->mmfree->next;
+       mm->endid++;    //end of list
 }
 
 void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
@@ -1562,7 +1696,8 @@ void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
        x->useptr=NULL;
        x->next=mm->mmfree;
        mm->mmfree=x;
-}
+       mm->endid--;    //end of list
+}*/
 
 void MM_seguin(void)
 {