]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.h
the near malloc is messy!! wwww
[16.git] / src / lib / 16_mm.h
index 7949cce4598964d0b36693c40541523de9fb4836..7425fc93b89c9affa2a8b5a9e0df79ae3493283c 100644 (file)
 #include <malloc.h>
 //#include <bios.h>
 #include "src/lib/16_head.h"
-#include "src/lib/modex16.h"
+#include "src/lib/16_hc.h"
+//#include "src/lib/modex16.h"
 //#include "src/lib/16_ca.h"
 //++++mh       #include "src/lib/16_in.h"
 
 #ifdef __DEBUG__               // 1 == Debug/Dev  ;  0 == Production/final
-#define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes"
+#define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes\n"
 #else
 #define OUT_OF_MEM_MSG "\npee\n"
 #endif
 
+//#define GETNEWBLOCK {if(!(mmnew=mmfree))Quit("MM_GETNEWBLOCK: No free blocks!") ;mmfree=mmfree->next;}
+#define GETNEWBLOCK {if(!mm->mmfree)MML_ClearBlock(mm);mm->mmnew=mm->mmfree;mm->mmfree=mm->mmfree->next;}
 
-#define SAVENEARHEAP   0x200           // space to leave in data segment
-#define SAVEFARHEAP    0//x2000                        // space to leave in far heap
+#define FREEBLOCK(x) {*x->useptr=NULL;x->next=mm->mmfree;mm->mmfree=x;}
+
+
+#define SAVENEARHEAP   0//_memavl()/4          // space to leave in data segment
+#define SAVEFARHEAP    0//x400                 // space to leave in far heap
 
 #define        BUFFERSIZE              0x1000          // miscelanious, allways available buffer
 
 #define        XMS_FREEUMB             0x11
 
 //==========================================================================
-//I hope this is correct!
-//__segment                seg;
-typedef void __based(__self) * memptr; //__based(seg) * memptr;
 
 typedef struct
 {
        dword   nearheap,farheap,EMSmem,XMSmem,mainmem;
        //__segment segu;
-       //word segu;
-//
 } mminfotype;
 
 //==========================================================================
@@ -122,11 +123,8 @@ extern void                (* XMSaddr) (void);             // far pointer to XMS driver
 
 typedef struct mmblockstruct
 {
-       word    start;//,length;
-       //dword start,length;
-       //word  start;
-       dword length;
-       //byte segm;                            //how many 64kb segment blocks it takes up if there is many data!
+       //word  start,length;
+       word    start;  dword length;
        unsigned        attributes;
        memptr          *useptr;        // pointer to the segment start
        struct mmblockstruct huge *next;
@@ -138,11 +136,12 @@ typedef struct
        memptr bufferseg;
        boolean         mmstarted, bombonerror, mmerror;
        void huge       *farheap;
-       void    *nearheap;
+       void __near     *nearheap;
        //byte          EMS_status;
        unsigned        totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
        unsigned int EMSVer;
        word numUMBs,UMBbase[MAXUMBS];
+       word    endid;  //end of list
        //dword numUMBs,UMBbase[MAXUMBS];
        mmblocktype     huge mmblocks[MAXBLOCKS],huge *mmhead,huge *mmfree,huge *mmrover,huge *mmnew;
 } mminfo_t;
@@ -192,8 +191,8 @@ dword MM_TotalFree(mminfo_t *mm);
 void MM_Report(/*page_t *page, */mminfo_t *mm, mminfotype *mmi);
 static void MM_EMSerr(byte *stri, byte err);
 void MM_BombOnError(boolean bomb, mminfo_t *mm);
-void MM_GetNewBlock(mminfo_t *mm);
-void MM_FreeBlock(mmblocktype *x, mminfo_t *mm);
+//void MM_GetNewBlock(mminfo_t *mm);
+//void MM_FreeBlock(mmblocktype *x, mminfo_t *mm);
 
 //==========================================================================