Mail Archives: djgpp/1999/09/09/12:38:33
On Thu, 9 Sep 1999, aperes wrote:
> Why this program receives SIGSEGV?
[snip]
> size_of_file = filelength(sound_handle);
> tmp_ptr = s_ptr =
> (unsigned char*)__dpmi_allocate_dos_memory((size_of_file+15) >> 4,
> selector); OK
>
>
> do { OK
> _dos_read(sound_handle, temp_ptr, 0x4000, &bytes_read);
You cannot read a file into a buffer (here tmp_ptr) that is allocated in
conventional memory. _dos_read (and most other DJGPP library functions)
only operate on buffers in extended memory.
In fact, your cast of the value returned by __dpmi_allocate_dos_memory to
a pointer is something that will never work: __dpmi_allocate_dos_memory
returns a real-mode segment of an allocated conventional memory buffer.
In contrast, C pointers are offsets relative to a protected-mode
selector. You cannot mix them.
What you need to do is to read the sound data into a normal buffer, e.g.
allocated by a call to malloc, and then move it into the conventional
memory using dosmemput. See section 18.4 of the FAQ for more details.
- Raw text -