[comp.sys.apple2] I need a little assistance

gt0t+@andrew.cmu.edu (Gregory Ross Thompson) (02/06/91)

  I'm trying to do something REALLY simple here, but it just doesn't
work.  All I wanna do is allocate a little memory, and then start up
the sound tools.  Can someone tell me why this little bit of code
doesn't work?

/* global vars */

Word                    MyID;
Handle                  STHandle;

void startup()
{
  int err=0;

  MyID = MMStartUp();
  STHandle = NewHandle((LongWord)0x100, MyID, 0xC005, NULL);
  SoundStartUp(*STHandle);
}

  From what I can tell, it's allocating the handle just fine, but when
it de-references it to a pointer, and sends it to SoundStartUp, it
crashes big time.  Am I doing something fundamentally wrong here?

		-Greg .

bazyar@ernie (Jawaid Bazyar) (02/06/91)

In article <wbfqYWu00WB7ADbEYc@andrew.cmu.edu> gt0t+@andrew.cmu.edu (Gregory Ross Thompson) writes:
>
>  MyID = MMStartUp();
>  STHandle = NewHandle((LongWord)0x100, MyID, 0xC005, NULL);
>  SoundStartUp(*STHandle);
               ^^^^^^^^^^^
  SoundStartUp takes a WORD as a parameter, whereas dereferencing a handle
defaults to a LONG pointer.  Change the call to the following and you should
be okay:

  SoundStartUp((word)*STHandle);

  This is Apple and Bytework's fault for neither one providing prototyped
tool headers- with prototyped headers, the compiler would have flagged an
error at this construct.
  There was some talk on GEnie or AOL about prototyped headers having been
created- I'll check that out.

--
Jawaid Bazyar               | "I'm sure K&R have never heard of Mike." 
Senior/Computer Engineering |
bazyar@cs.uiuc.edu          | "That's okay. I'm sure Mike's never heard of K&R".
   Apple II Forever!        |  (discussion about Orca/C)