home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!pageworks.com!world!eff!sol.ctr.columbia.edu!usc!elroy.jpl.nasa.gov!ames!data.nas.nasa.gov!taligent!kip-16.taligent.com!user
- From: keith@taligent.com (Keith Rollin)
- Subject: Re: faulty ANSI in Think C 5.0?
- Message-ID: <keith-171192135605@kip-16.taligent.com>
- Followup-To: comp.sys.mac.programmer
- Sender: usenet@taligent.com (More Bytes Than You Can Read)
- Organization: Taligent
- References: <1992Nov16.211648.23619@math.ucla.edu> <1ebg9lINNi8e@terminator.rs.itd.umich.edu>
- Date: Tue, 17 Nov 1992 22:01:26 GMT
- Lines: 46
-
- In article <1ebg9lINNi8e@terminator.rs.itd.umich.edu>,
- potts@oit.itd.umich.edu (Paul Potts) wrote:
- >
- > In article <1992Nov16.211648.23619@math.ucla.edu> dchopp@vicente.math.ucla.edu (David Chopp) writes:
- > >I'm curious if others have run into similar problems as I regarding using
- > >some ANSI subroutines in Think C 5.0.2 with TCL. In particular, I have
- > >trouble using strcpy, strcmp, sprintf, to name a few. I have found them
- > >to be sporadic in working properly and I'm wondering if I'm doing something
- > >wrong. For example, in one object, I'll have two methods each using strcpy
- > >in them (all in the same file). In one context, it works perfectly, in the
- > >other it fails to copy. The arguments being passed are all correct (I've
- > >checked them several times).
- >
- > I'd say it is most likely that there is a problem in your program. I've
- > used sprintf, strcpy, strcmp, etc. and had them work fine.
- >
- > Some things to consider: are you testing the arguments under the source-level
- > debugger, or at runtime under MacsBug? The source-level debugger and the
- > low-level debugger can show different things. Under the source debugger
- > sometimes memory is better initialized, pointers tend not to penalize you
- > for writing to stray addresses, etc. Whenever I've had problems using
- > the string routines, they were caused by some other part of my code which
- > was trashing memory at runtime.
-
- Another thing that occurs to me is that there could be problems if the
- strings are data members of handle-based objects, and the ANSI routines are
- in an unloaded code segment. If that's so, then a call like:
-
- strcmp(fMyString, "Test string");
-
- can fail. This is because calling strcmp() will cause the code segment
- containing it to be loaded. This loading could cause the object owning
- fMyString to move AFTER its address has been taken and placed on the stack.
-
- If this is the problem, there are at least three solutions:
-
- 1) lock the object containing fMyString.
- 2) make sure the ANSI library is in a resident segment
- 3) copy fMyString into a local variable (oops! this requires access to
- strcpy!
- infinite page fault has occured -- shutting down...)
-
- -----
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-