www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/09/12:38:33

Date: Thu, 9 Sep 1999 13:28:34 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: aperes <ajps AT mail DOT telepac DOT pt>
cc: djgpp AT delorie DOT com
Subject: Re: SIGSEGV
In-Reply-To: <37d738ad.581052@news.telepac.pt>
Message-ID: <Pine.SUN.3.91.990909132222.7977A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019