From: Nick Friend on 30 Apr 2010 09:48 Can someone clarify the following please... A function declaration like : _DLL FUNC AdsDDFindNextObject( hObject AS DWORD, hFindHandle AS DWORD, pucObjectName AS PSZ, pusObjectNameLen REF WORD ) AS DWORD PASCAL:ACE32.AdsDDFindNextObject The parameter pucObjectName is set up with pszObjectName:=MemAlloc(500) (or whatever value) Is there any difference or preference between declaring LOCAL pszObjectName AS PSZ and testing for !=NULL_PSZ after the MemAlloc call and LOCAL pszObjectName AS PTR and testing for !=NULL_PTR after the MemAlloc call TIA Nick
From: Geoff Schaller on 30 Apr 2010 20:14 Nick, The issue is one of type comparison. If the prototype calls for a PSZ (which is a pointer to a memory location of a null terminated string) then use the psz comparison. A ptr can point to the same buffer so mechanically you can use both but isn't it just more practical to stay with the same data type. Also, why would you bother testing for a valid pointer from a MemAlloc()?? Under what circumstances could it possibly fail? Unless you expected to ride right up to the maximum of your memory allocation, such testing is a waste of time. ...and what would you do if it failed anyway <g>. Geoff "Nick Friend" <nicktekhne(a)googlemail.com> wrote in message news:6bb0507c-cc42-4775-b9b8-afd120e822f3(a)x20g2000yqb.googlegroups.com: > Can someone clarify the following please... > > A function declaration like : > > _DLL FUNC AdsDDFindNextObject( hObject AS DWORD, hFindHandle AS DWORD, > pucObjectName AS PSZ, pusObjectNameLen REF WORD ) AS DWORD > PASCAL:ACE32.AdsDDFindNextObject > > The parameter pucObjectName is set up with > > pszObjectName:=MemAlloc(500) (or whatever value) > > Is there any difference or preference between declaring > LOCAL pszObjectName AS PSZ > and testing for !=NULL_PSZ after the MemAlloc call > and > LOCAL pszObjectName AS PTR > and testing for !=NULL_PTR after the MemAlloc call > > TIA > > Nick
From: Nick Friend on 1 May 2010 02:28 Thanks Geoff, confirmed what I more or less thought. What would I do if it failed.... well at least I wouldn't try to use the pointer! Nick On 1 May, 01:14, "Geoff Schaller" <geo...(a)softxwareobjectives.com.au> wrote: > Nick, > > The issue is one of type comparison. If the prototype calls for a PSZ > (which is a pointer to a memory location of a null terminated string) > then use the psz comparison. A ptr can point to the same buffer so > mechanically you can use both but isn't it just more practical to stay > with the same data type. > > Also, why would you bother testing for a valid pointer from a > MemAlloc()?? Under what circumstances could it possibly fail? Unless you > expected to ride right up to the maximum of your memory allocation, such > testing is a waste of time. ...and what would you do if it failed anyway > <g>. > > Geoff > > "Nick Friend" <nicktek...(a)googlemail.com> wrote in message > > news:6bb0507c-cc42-4775-b9b8-afd120e822f3(a)x20g2000yqb.googlegroups.com: > > > > > Can someone clarify the following please... > > > A function declaration like : > > > _DLL FUNC AdsDDFindNextObject( hObject AS DWORD, hFindHandle AS DWORD, > > pucObjectName AS PSZ, pusObjectNameLen REF WORD ) AS DWORD > > PASCAL:ACE32.AdsDDFindNextObject > > > The parameter pucObjectName is set up with > > > pszObjectName:=MemAlloc(500) (or whatever value) > > > Is there any difference or preference between declaring > > LOCAL pszObjectName AS PSZ > > and testing for !=NULL_PSZ after the MemAlloc call > > and > > LOCAL pszObjectName AS PTR > > and testing for !=NULL_PTR after the MemAlloc call > > > TIA > > > Nick- Hide quoted text - > > - Show quoted text -
|
Pages: 1 Prev: All User v specific user installation options Next: ToolTip text in 2830 |