 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alien Guest
|
Posted: Sat Mar 31, 2007 11:37 pm Post subject: Memory leak? |
|
|
Using Delphi7
I am using FastMM4 and it shows thet I am getting a memory leak with the code below.
What can I do to fix it with your help that is.
procedure TProject1.GetMyPostedMid; ///
var
P, Q, Temp: PChar;
XFace: array[0..1024] of Char;
begin
P := ReadWrite.GetText; // ReadWrite is a TStringList
Q := StrNew(P);
begin
P := StrPos(Q, 'Message-ID: ');
if P <> nil then
P := P + 12;
Temp := StrPos(P, #13#10);
Temp^ := #0;
StrLCopy(XFace, P, SizeOf(XFace) - 1);
Memo1.Lines.Add(Trim(XFace)); // Adds the Message-ID: <blblbl@watever> to Memo1
end;
end;
--
-A-l-i-e-n- |
|
| Back to top |
|
 |
Vertuas Guest
|
Posted: Mon Apr 16, 2007 2:24 am Post subject: Re: Memory leak? |
|
|
"Alien" <aliens (AT) Earth (DOT) humans> wrote in message
news:LdYRmcI0Nf3riUlQ0sVaEdaliens (AT) Earth (DOT) humans...
| Quote: | Using Delphi7
I am using FastMM4 and it shows thet I am getting a memory leak with the
code below.
What can I do to fix it with your help that is.
procedure TProject1.GetMyPostedMid; ///
var
P, Q, Temp: PChar;
XFace: array[0..1024] of Char;
begin
P := ReadWrite.GetText; // ReadWrite is a TStringList
Q := StrNew(P);
begin
P := StrPos(Q, 'Message-ID: ');
if P <> nil then
P := P + 12;
Temp := StrPos(P, #13#10);
Temp^ := #0;
StrLCopy(XFace, P, SizeOf(XFace) - 1);
Memo1.Lines.Add(Trim(XFace)); // Adds the Message-ID: <blblbl@watever> to
Memo1
end;
end;
--
-A-l-i-e-n-
|
Q:=StrNew(p);
this line allocates memory to create a new instance of P
you need to free this memory. |
|
| Back to top |
|
 |
|
|
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
|
|