Re: Freeing a record which contains a string field leads to a memory/string leak ?!
From: Skybuck Flying (nospam_at_hotmail.com)
Date: 02/21/04
- Next message: Skybuck Flying: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Previous message: Skybuck Flying: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- In reply to: Rob Kennedy: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Next in thread: Rob Kennedy: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Reply: Rob Kennedy: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 21 Feb 2004 03:06:15 +0100
> > But but but but but this raising a somewhat little interesting
> > question if you guys also new a 'legal' trick to keep the string
> > alive but so that delphi does destroy the string when the pointer
> > goes dead or is reassigned something else whatever.
>
> There is no legal solution to the problem you posed. You're giving P a
> pointer to a stack variable. As soon as the procedure returns, that
> pointer will be invalid. The fact that P is pointing to a *string*
> variable is totally irrelevant. If you want the pointer to remain valid
> after the procedure returns, then you need to make it point to memory
> allocated on the heap, not on the stack.
P is not on the stack, P is outside the procedure. I think you mean the
string should be allocated on the heap.
How does one allocate a string on the heap ?
- Next message: Skybuck Flying: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Previous message: Skybuck Flying: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- In reply to: Rob Kennedy: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Next in thread: Rob Kennedy: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Reply: Rob Kennedy: "Re: Freeing a record which contains a string field leads to a memory/string leak ?!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|