
August 15th, 2004, 04:01 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 12
Time spent in forums: 1 m 7 sec
Reputation Power: 0
|
|
|
Access vilation : pointer to a record
I have the folowing code, where lptNewMessage is a pointer to my record type (PTMessageConv).
New(lptNewMessage);
lptNewMessage^.sMessage := 'adasdasdas';
lptNewMessage^.sHasNotRead := 'asdasdasds';
Dispose(lptNewMessage);
I get an access violation error on the 3rd line. Is it because my String exceeds the allocated memory for the pointer? I don't know how the String really works, but shouldn't it take care of it's own memory needs?
Here's my record type :
PTMessageConv = ^TMessageConv;
TMessageConv = class(TObject)
sMessage : String;
sHasNotRead : String;
end;
Edit : If I swap the 2nd and 3rd line of code, it will crash on the 2nd line instead of the 3rd. And if I swap the 2 elements of my definition, it will crash on the 2nd line instead of the 3rd. So it has something to do with the last field of my record.
|