You are mixing open and close.
If open fails, then nothing happens. You have to ensure yourself that everything you allocated before you detect the failure is freed.
Close will only be called if open succeeded. Close should expunge the library only if a previous call to expunge failed because the library was still opened.
|