shawn857
asked on
"Freemem" statement now gives "Invalid Pointer Operation". Used to work OK.
Hello Experts... I have a routine which would read a "chunk" of bytes from a file using a stream, do a bit of processing, then write that chunk to an output stream.. and repeat this till nothing left to read. Before the read I have these statements:
Chunksize := 2048000;
GetMem(CopyBuffer, ChunkSize); // CopyBuffer is defined as a PChar
And I do the read as such:
ibytesOK:=InfileStream.Rea d(CopyBuff er^, ChunkSize);
At the end when cleaning things up and closing files, I have this statement:
FreeMem(CopyBuffer, Chunksize);
This all used to work fine, until I just added some code that steps through the CopyBuffer a bit, looking for a #13 character:
while CopyBuffer^ <> #13 do
Inc(CopyBuffer);
Now when I run it, it crashes on the FreeMem(CopyBuffer, Chunksize); statement giving "Invalid Pointer Operation". Any idea how to remedy this, anyone?
Thanks!
Shawn
Chunksize := 2048000;
GetMem(CopyBuffer, ChunkSize); // CopyBuffer is defined as a PChar
And I do the read as such:
ibytesOK:=InfileStream.Rea
At the end when cleaning things up and closing files, I have this statement:
FreeMem(CopyBuffer, Chunksize);
This all used to work fine, until I just added some code that steps through the CopyBuffer a bit, looking for a #13 character:
while CopyBuffer^ <> #13 do
Inc(CopyBuffer);
Now when I run it, it crashes on the FreeMem(CopyBuffer, Chunksize); statement giving "Invalid Pointer Operation". Any idea how to remedy this, anyone?
Thanks!
Shawn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers
Shawn