Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!smurf!urlichs From: urlichs@smurf.sub.org (Matthias Urlichs) Newsgroups: comp.sys.mac.programmer Subject: Re: CtoPstr Message-ID: Date: 14 Dec 90 22:14:19 GMT References: <18153@shlump.nac.dec.com> Organization: University of Karlsruhe, FRG Lines: 29 In comp.sys.mac.programmer, article <18153@shlump.nac.dec.com>, vandevyver@cuvee.enet.dec.com writes: < < [ talking about CtoPstr ] < < just declare the string as a normal c string, but, make it big enough (at leat < 1 bigger than needed. < Actually, no. The C string will have a zero byte at the end and the Pascal string has a length byte in front -> no size difference. < And beware : CtoPstr will modify the ORIGINAL string, so you cannot call this < function twice without re-initialisation! < In other words, _never_ use it on constants, as in CtoPstr("xyzzy") That code will work exactly once. It might also not be a good idea to use the UPPERCASE names for some toolbox routines (which call CtoPstr internally, make the toolbox call, and then call PtoCstr on the string again to pretend that nothing has happened). Performance can only get worse when you do things like that; besides, modifying your code resources (if you let the compiler put string constants in code) is frowned upon, as it may break in the future. -- Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de /(o\ Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330) \o)/