From: jonslaughter AT my-dejanews DOT com Newsgroups: comp.os.msdos.djgpp Subject: __dpmi_resize_dos_memory problem(not working?) Date: Mon, 17 Aug 1998 08:33:29 GMT Organization: Deja News - The Leader in Internet Discussion Lines: 103 Message-ID: <6r8psp$qmm$1@nnrp1.dejanews.com> NNTP-Posting-Host: 38.11.206.18 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk sorry if I have already posted this(having problems with news servers)... I'm having a HUGE problem trying to get __dpmi_resize_dos_memory to work... it always fails and I don't understand why... since I'm only shrinking the memory block I don't see why it should fail(jus has to lower the segment limit in the descriptor?). Anyways, I've done alittle test program to show you what I'm trying to do. just allocate, resize, and free a dos block. From what I understand this should work, so what am I missing?? please help me ;) I'm desprate. when I run it, I get a very low free dos memory(like 3k). What I'm trying to do is create a function that allocate a dos memory that doesn't cross a 64k segment boundry... they way I'm doing this is explained at the bottom. if you can help me, please email me at 1jjs5206 AT csunix DOT mcc DOT cc DOT tx DOT us , since I do not know if I can get back on the new group.... Thanks. #include #include #include #include void main (void) { int sel, seg, memsize, new_memsize, total_mem, retval; memsize = 0x100; new_memsize = 0x90; printf("Allocating %d bytes of dos memory...\n\n",memsize); seg = __dpmi_allocate_dos_memory(memsize >> 4,&sel); if (seg == -1) { printf("Error allocating dos memory\n"); exit(1); } printf("Resizing %d bytes to %d bytes of dos memory...\n\n",memsize,new_memsize); retval = __dpmi_resize_dos_memory(sel, new_memsize >> 4,&total_mem); printf("Total Memory avaliable = %d\n",total_mem << 4); if (retval == -1) { __dpmi_free_dos_memory(sel); printf("Error resizing dos memory block"); exit(1); } __dpmi_free_dos_memory(sel); printf("Dos memory successfully allocated, resized, and freed\n"); } to allocate a block of mem that doesn't cross a 64k seg boundry, I do the following pseudo code: memsize < 64k allocate memory. do { if (dosmemseg < (int)(dosmemseg/0xFFF+1)*0xFFF) && ((16*dosmemory + memsize) < (int)(dosmemseg/0xFFF+1)*0xFFF) { dosmemseg does not cross 64k bound, mem ok. return dosmemseg; } resize dosmemseg to end just at end of 64k bound... ***** problem occurs here, just as in sample code above ***** allocate new_dosmemseg hoping that it would start right after dosmemseg free dosmemseg dosmemseg = new_dosmemseg; while (retry count == ok) -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum