BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: "Invalid Pointer Operation" when using Dispose() or Free

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Jerry
Guest





PostPosted: Mon Jan 03, 2005 10:18 pm    Post subject: Re: "Invalid Pointer Operation" when using Dispose() or Free Reply with quote



Hey, your answer hellped me find my problem: using a pointer to a
pointer.

I ended up writing to memory I allocated, but freed the wrong pointer.
After I figured out what I had done, everything worked just fine!

Brien King wrote:
Quote:
(***************Here's the trouble
*****************************)
new(ThePFI); {<==========
method# 1}
GetMem(ASecondPFI, sizeof(TVS_FixedFileInfo)); {<=====method
#2}
pchar(AThirdPFI):=StrAlloc(Sizeof(TVS_FIXEDFILEINFO));
{<=The hack, #3}
VerQueryValue(pszData, '', pointer(ThePFI) , wLen);
VerQueryValue(pszData, '', pointer(ASecondPFI) , wLen);
VerQueryValue(pszData, '', pointer(AThirdPFI) , wLen);
StrDispose(pszData);
Strdispose(pchar(AThirdPFI)); {<==The hack works}
Dispose(ThePFI); {<==Invalid Pointer
Operation"!}
FreeMem(ASecondPFI, sizeof(TVS_FixedFileInfo)); {<==also
invalid}
end.

Since "ThePFI" is already a Pointer, why the pointer(ThePFI)? This
could be your problem. Since I do not know what VerQueryValue does
with the parameters (nor how they are actually defined) I would say
this is your problem. It looks as though your attempting to pass the
structure in by Reference and then fill it in. However, what you may
actually be doing is passing in an Invalid Pointer, or a pointer to
the pointer (can't remember off the top of my head what pointer(x)
does). If you try your code without the VerQueryValue in the middle
so all you have is New(ThePFI) and then Dispose(ThePFI) I bet it
would
work.

Brien King
[email]bking (AT) primenet (DOT) com[/email]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.