home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!swrinde!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!kth.se!dront.nada.kth.se!d88-jwa
- From: d88-jwa@dront.nada.kth.se (Jon W{tte)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Inconsistantcy in Think C
- Message-ID: <D88-JWA.92Aug30221950@dront.nada.kth.se>
- Date: 30 Aug 92 21:19:50 GMT
- References: <1992Aug30.091804.1@acad2.alaska.edu>
- Sender: usenet@kth.se (Usenet)
- Organization: Royal Institute of Technology, Stockholm, Sweden
- Lines: 35
- In-Reply-To: asmah@acad2.alaska.edu's message of 30 Aug 92 13:18:04 GMT
- Originator: d88-jwa@dront.nada.kth.se
- Nntp-Posting-Host: dront.nada.kth.se
-
- > asmah@acad2.alaska.edu writes:
-
- I have a sprintf() statement which doesn't work the first time through, but
- works during a second time. As far as I can tell, all the variables are
- identical during both passes. This is what it looks like.
-
- CharsHandle input;
- TEHandle TEFields[20];
-
- input = TEGetText(TEFields[0]);
- sprintf((**ARH.c_employee).last_name,"%.*s",(**TEFields[0]).teLength,(**input));
- return 1;
-
- Are you sure it says **input? Since that would be a char, not a char
- pointer, as you would want when passing %s.
-
- Anyway, you are probably calling sprintf from another segment which
- makes a segment load which moves memory which makes your de-referenced
- handle move. Lock it first:
-
- char state ;
-
- input = ....
- state = HGetState ( input ) ;
- HLock ( state ) ;
- sprintf ( ... ) ;
- HSetState ( input , state ) ;
-
-
- More about this in the chapter about the memory manager in IM II.
-
- --
- Jon W{tte, h+@nada.kth.se, Sweden, Phone +46-8-107069
- White, Literate, Employed, Higher-Educated, Male, Straight and Not Poor.
- I must be a bad guy.
-