Date: Thu, 9 Sep 1999 13:28:34 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: aperes cc: djgpp AT delorie DOT com Subject: Re: SIGSEGV In-Reply-To: <37d738ad.581052@news.telepac.pt> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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.