[net.micro.amiga] FreeDiskObject

wutka@gitpyr.UUCP (Mark Wutka) (03/13/86)

  I don't know if anyone else has had trouble getting Amiga Hack to work
but I have...actually, the only problem I have had is in the save command.
When I tried to save a game it hung...I traced the problem all the way
down to the FreeDiskObject call in makeicon. Is there something wrong
with this routine ??  Or maybe does PutDiskObject deallocate the object
by itself ??  I commented out the call and the save function worked, but
I assume that I will be wasting a small amount of memory every time I save
a game since I won't be freeing that memory when I am done...any solutions
or suggestions ??

-- 
Mark Wutka
Office of Computing Services
Georgia Institute of Technology
Atlanta, Ga.

...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!wutka
...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!wutka

Official member of NERDS (NERDS Existing in a Recursively Defined System)

wjr@utcs.uucp (William Rucklidge) (03/20/86)

In article <1538@gitpyr.UUCP> wutka@gitpyr.UUCP (Mark Wutka) writes:
>   I don't know if anyone else has had trouble getting Amiga Hack to work
> but I have...actually, the only problem I have had is in the save command.
> When I tried to save a game it hung...I traced the problem all the way
> down to the FreeDiskObject call in makeicon. Is there something wrong
> with this routine ??
> Mark Wutka
> ...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!wutka
> ...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!wutka


Well, there is nothing wrong with this routine, but there are a couple of
problems with the code around it: the routine is
makeicon, in hack.icon.c (in part 10 of the posting). The original code
reads:

	if ( (object = GetDiskObject(source)) == NULL)
		myprintf("Cannot get source icon - err #%d\n", IoErr() );
	object->do_CurrentX = NO_ICON_POSITION;
	object->do_CurrentY = NO_ICON_POSITION;
	if ( (object = PutDiskObject( name, object )) == NULL)
		myprintf("Cannot create save icon - err #%d\n", IoErr() );
	FreeDiskObject(object);

which I have modified to read:

   if ( (object = GetDiskObject(source)) == NULL) {
      myprintf("Cannot get source icon - err #%d\n", IoErr() );
   } else {
      object->do_CurrentX = NO_ICON_POSITION;
      object->do_CurrentY = NO_ICON_POSITION;
      if ( (PutDiskObject( name, object )) == NULL)
         myprintf("Cannot create save icon - err #%d\n", IoErr() );
      FreeDiskObject(object);
      }

which seems to work fine, whether the icons exist or not.
The problem is that the routine PutDiskObject was returning a status, which
was overwriting the pointer to the object. Later, freeing that pointer
caused the crash.

My copy of hack still has a problem, though - attempting to wield bare hands
causes a Task Held error... I haven't been able to figure this one out yet.
Oh well...

-- 
William Rucklidge	University of Toronto Computing Services
{decvax,ihnp4,utcsri,{allegra,linus}!utzoo}!utcs!wjr
GISO - Garbage In, Serendipity Out.
This message brought to you with the aid of the Poslfit Committee.