[comp.sys.mac.programmer] GetScrap problem

jrk@information-systems.east-anglia.ac.uk (Richard Kennaway CMP RA) (01/22/91)

In someone's code, I saw this:

>	h = NewHandle(0);
>	length = GetScrap(h,theType,&offset);

I've had problems with reading the scrap that way.  Reading a large 'TEXT' 
scrap, I sometimes find that I end up with junk in the handle, as if it got
moved after the scrap was read into it, but without its contents being
copied.  Instead I ensure the handle is already big enough:

	length = GetScrap( nil, theType, &offset );
	h = NewHandle( length );
	GetScrap( h, theType, &offset );

(I've left out the checking for length<0 or h==nil that a real program
would do.)

I find this works; but nothing I've seen in IM or the TNs suggests that the
previous code should fail.   What is going on?

--
Richard Kennaway          SYS, University of East Anglia, Norwich, U.K.
Internet:  jrk@sys.uea.ac.uk		uucp:  ...mcsun!ukc!uea-sys!jrk