AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Should I CloseHandle(plugin) ??? (https://forums.alliedmods.net/showthread.php?t=290803)

Neuro Toxin 11-24-2016 00:39

Should I CloseHandle(plugin) ???
 
The below loops through plugins using the plugin iterator.

Code:

public void _Dynamic_HandleUsage()
{
        // Loop plugins
        Handle iterator = GetPluginIterator();
        Handle plugin;
        while (MorePlugins(iterator))
        {
                plugin = ReadPlugin(iterator);
        }
        CloseHandle(iterator);
}

Will this leak as I need to call CloseHandle(plugin); ?

hleV 11-24-2016 02:55

Re: Should I CloseHandle(plugin) ???
 
Yes.
https://sm.alliedmods.net/new-api/so...PluginIterator

Neuro Toxin 11-24-2016 02:57

Re: Should I CloseHandle(plugin) ???
 
I already close the iterator handle.

The question is do i need to close the plugin handles.

ddhoward 11-24-2016 03:07

Re: Should I CloseHandle(plugin) ???
 
You shouldn't need to do this. I think closing that handle may actually cause the plugin to screw up? Imma test it out real fast.

EDIT: Nevermind. Plugin handles are unclosable.

https://wiki.alliedmods.net/Handles_...pting)#Plugins

Neuro Toxin 11-24-2016 03:07

Re: Should I CloseHandle(plugin) ???
 
Thats what i thought. Just afk atm so cant test

Powerlord 11-24-2016 03:08

Re: Should I CloseHandle(plugin) ???
 
You could always check and see if you get an error about not having permissions to close said handles.

I'm guessing you don't need to close them as they're likely owned by Core, same as CVar Handles.

ddhoward 11-24-2016 03:15

Re: Should I CloseHandle(plugin) ???
 
I edited my previous post with my findings, before I saw that people had replied.

Plugin handles are owned by Core, and cannot be closed or cloned.

Neuro Toxin 11-24-2016 03:31

Re: Should I CloseHandle(plugin) ???
 
Sweet. Thanks everyone


All times are GMT -4. The time now is 01:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.