delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/09/03:43:12

From: ajps AT mail DOT telepac DOT pt (aperes)
Newsgroups: comp.os.msdos.djgpp
Subject: SIGSEGV
Date: Thu, 09 Sep 1999 04:49:31 GMT
Lines: 83
Message-ID: <37d738ad.581052@news.telepac.pt>
NNTP-Posting-Host: 194.65.163.218
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Why this program receives SIGSEGV?

typedef      struct SNDSTRUC_typ
             {
                unsigned short sound;
                unsigned short sndlen; 
                short *IsPlaying;       
                short frequency;       
             } SNDSTRUC, *SNDSTRUC_PTR;


typedef       struct sound_typ
              {
                 unsigned char *buffer; 
                 short status;          
                 SNDSTRUC SS;          
              } ssound, *ssound_ptr;


int main(void)
{
 ......

Load_Sound(..............);

.......

return 0;
}


int Sound_Load(char *filename, ssound_ptr the_sound, int translate)
{
  ......
  ......
  int *selector;
  ..........

  if(_dos_open(filename, _O_RDONLY, &sound_handle)) {          OK
     printf("file not found");
     return 1;
  }

  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);
     // update pointer
     temp_ptr += bytes_read;
  } while (bytes_read == 0x4000);

  // fechar ficheiro   OK
  _dos_close(sound_handle);

  header_length = s_ptr[20];   OK

  the_sound->buffer = s_ptr;   OK

  // set SNDSTRUC for DIGPAK - OK
  the_sound->SS.sound = (unsigned short)(s_ptr + header_length + 4);
  the_sound->SS.sndlen = (unsigned short)(size_of_file -
header_length);
  the_sound->SS.IsPlaying = (short *)(&the_sound->status);
  the_sound->SS.frequency = (short) ( (long)(-1000000) /

((int)s_ptr[header_length+4]-256));


  return 0;          OK

} // fim da funcao Sound_Load  <---- ABORT: SIGSEGV!!!


( from "The Black Art of 3D Programming", Andre LaMothe)

Thanks in advance

Aperes

- Raw text -


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