Re: [fpc-pascal] Freeing memory with exceptions

2023-05-21 Thread Michael Van Canneyt via fpc-pascal
On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote: On May 21, 2023, at 2:47 PM, Michael Van Canneyt via fpc-pascal wrote: Your example will leak memory in any case, even if there is no exception, since you're not freeing the object anywhere.. doh, dumb example on my behalf.

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-21 Thread Hairy Pixels via fpc-pascal
> On May 21, 2023, at 2:47 PM, Michael Van Canneyt via fpc-pascal > wrote: > > Your example will leak memory in any case, even if there is no exception, > since you're not freeing the object anywhere.. doh, dumb example on my behalf. > > Assuming the result of A is not used outside of

Re: [fpc-pascal] Freeing memory with exceptions

2023-05-21 Thread Michael Van Canneyt via fpc-pascal
On Sun, 21 May 2023, Hairy Pixels via fpc-pascal wrote: I've never really used exceptions myself in Pascal (with the exception of breaking out of deeply recursive function calls) so I don't know all the rules. In this example lets say you call Test() which allocates some memory and then