Mail Archives: djgpp/1997/07/04/14:15:54
At 01:55 7/4/1997 +0800, you wrote:
>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.
A pointer returned by malloc is exactly like any other data pointer (ie: int
i; &i). It is a 32-bit offset from your program's base. It is relative to
your DS selector, which you can get with _my_ds() from sys/segments.h.
>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);
Try this:
int len=2*640*480;
char *p; /* or void *p */
p = malloc(len)
if (p == NULL) /* barf out, there's no more memory */;
movedata(video_ds,0,_my_ds(),(unsigned)p,len);
/* stuff */
movedata(_my_ds(),(unsigned)p,video_ds,0,len);
Hope this helps.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -