TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Daniel Lynes
from: Darin McBride
date: 1996-07-04 22:26:00
subject: VioGetCurType()

PC> Because CursorData is declared as a pointer, but is never
 PC> allocated any memory.

 DL> That's what I thought, but wasn't sure if the function 
 DL> did an internal allocation or not, as the example code 
 DL> offered by IBM does not show any memory allocation 
 DL> before calling the function.

None of IBM's documentation in the PRCP.INF file seems to do that without a
full function surrounding it.

As for 'internal allocation' - it's a pretty safe bet that it doesn't.  The
only time that OS/2 will do "internal allocation" in an API is if
you have to also call a "close" function, i.e. handles to
anything (windows, files, whatever).  The reason is that you cannot call
free() (or delete [C++] or dispose [Pascal]) on memory that is not
allocated by YOUR run-time library (especially when all the above
languages, plus more, must be able to de-allocate it!).  The only exception
here is REXX DLL's, but the 'free' function is documented as
"DosFreeMem" (IIRC).

This is something I found out while writing Windows DLL's.  Even when two
programs are written with the same compiler (say Borland C++ 4.52), they
cannot free memory allocated by the other.  They can USE the memory, but
cannot free it.  This is because the DLL/Process/API are all using
different heaps.

In this way, unless the documentation explicitly tells you to use a certain
API to clean it up, you have to provide the memory.


Oh, and think about this for a second...

static PCURSORINFO CursorInfo;

VioGetCurType(CursorInfo, 0);

Let's say CursorInfo, being static, is initialized, as per the standard, to
0.  You are passing a NULL pointer to VioGetCurType.  How is VioGetCurType
supposed to return the memory it would create for you?  It returns a
USHORT, not a PCURSORINFO... you would have to pass in the address of your
pointer for it to change your pointer to the allocated memory... :-)

I would say the documentation is poor, and that they assumed that we would
think like they do.  We're not all IBM employees!  :-)

Have a good one,


--- Maximus/2 3.01
* Origin: Tanktalus' Tower BBS (PVT) (1:342/708)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 517 628 713/888 800/1
@PATH: 342/5015 61 3615/50 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.