#Freeing memory from struct

1 messages · Page 1 of 1 (latest)

slow magnet
#

edit: when error happens, defer is interrupted

#

sorry

sterile rover
#

Panic you mean?

#

Defer is still ran when you return error.something

slow magnet
proper hemlock
#

errdefer

keen gulch
#

wait @panic runs things in errdefers?

#

is that what youre saying?

meager glacier
#

Use errdefer for early resource cleanup upon returning an error, if that's what you mean.

Not sure what the question is beyond that

#

Panic is noreturn, so whatever defer you have will never run because the program will just exit. So freeing memory is not really important. But you can free just before the panic if you want to "not leak"