Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!mips!sjsca4!poffen From: poffen@sj.ate.slb.com (Russell Poffenberger) Newsgroups: comp.windows.ms Subject: Re: Show-stopper in wstdio.c/3.0 SDK tty sample app Keywords: Win 3.0 SDK, tty sample app, wstdio.c, LocalAlloc, LocalLock Message-ID: <1990Sep24.201443.1377@sj.ate.slb.com> Date: 24 Sep 90 20:14:43 GMT References: <6589@sugar.hackercorp.com> Reply-To: poffen@sj.ate.slb.com (Russell Poffenberger) Organization: Schlumberger Technologies, San Jose, CA. Lines: 33 In article <6589@sugar.hackercorp.com> karl@sugar.hackercorp.com (Karl Lehenbauer) writes: >The wstdio.c module in the tty sample application has some code that >is a guaranteed GP ever time. > >In the initialization routine, stdioInit, the code does a LocalAlloc >to get a handle to some memory to use for registering a class with >windows. It then CASTS THE HANDLE TO A POINTER AND TRIES TO REFERENCE >FIELDS WITH IT! Looks like it needs to do a LocalLock on the >handle and use the address returned by LocalLock as a pointer, eh? If I remember right, this is OK if the LocalAlloc specified LMEM_FIXED as a flag. This means that the memory can't be moved or discarded by windows so the handle returned is the same as the pointer to the actual memory allocated. This is still not recommended however, especially for GlobalAlloc. > >I guess just having a WNDCLASS structure created on the stack is no >good unless you know you're going to be large model only since >DS != SS. > >By the way, with respect to all the people who are down on large model, >how big are your applications, anyway? 64K of code space doesn't really >go very far for any "real" application, I don't think. Use the medium model, then you aren't limited to 64K, except for any single module. If you split up your source into several modules, then you can get multiple code segments. (Don't forget that routines are now FAR. Russ Poffenberger DOMAIN: poffen@sj.ate.slb.com Schlumberger Technologies UUCP: {uunet,decwrl,amdahl}!sjsca4!poffen 1601 Technology Drive CIS: 72401,276 San Jose, Ca. 95110 (408)437-5254