From: csgcty AT singnet DOT com DOT sg Date: Fri, 4 Jul 1997 13:55:19 +0800 (SST) Message-Id: <199707040555.NAA16962@mallow.singnet.com.sg> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: djgpp AT delorie DOT com Subject: Re: Memory allocation Cc: Nate Eldredge , Eli Zaretskii Precedence: bulk Thanks for the replies! >You wrote: >>I just started using DJGPP and I'm a little confused about memory >>allocation. There appears to be a few ways to allocate memory : using the >>new operator, using __dpmi_allocate_dos_memory, >>__dpmi_allocate_linear_memory, __dpmi_allocate_memory, >>__dpmi_allocate_shared_memory. Could someone tell me which one I should use >>and what is the difference between them ? I need to allocate about 1-2 MB. > >Is there some reason you can't just use malloc? This is the most portable >and simplest way to allocate memory, and all the low-level DPMI stuff is >done for you. > The pointer returned by malloc, what kind of pointer is it ? is it a 32 bit offset from somewhere (where ?)? what I need is a offscreen buffer for the screen. What I did was : int len=2*640*480; char *p; int p_ds; p=malloc(len); p_ds=__dpmi_allocate_ldt_descriptors(1); __dpmi_set_segment_base_address(p_ds,(int)p); __dpmi_set_segment_limit(p_ds,len); //video_ds defined elsewhere movedata(video_ds,0,p_ds,0,len); //do something movedata(p_ds,0,video_ds,0,len); The problem was that when len was not too large (< approx 200K) it was okay, but when it got larger than that, only part of the screen was restored other parts were filled with either static or white. Please help ! Thanks Chan Tze Yi