Page 1 of 1

little issue in plugin API

Posted: Wed Jun 21, 2006 4:27 am
by peter
Scott,

I believe I found a little problem. My understanding is as follows: using the method GetDeviceFromDescription a new CDevice instance will be created. This class is initialized passing the value for m_szDeviceName from pHB_GetDeviceInfoFromDescription. So far ok. But the m_szDeviceDescription will be initialized with the value originally passed by GetDeviceFromDescription. This could be a temporary memory. Instead of this, the szDeviceDescription should be initialized with a persistent value gathered from the server or it should get new own memory.

Can you confirm this?
peter

Re: little issue in plugin API

Posted: Wed Jun 21, 2006 9:15 am
by ScottBot
peter wrote:Can you confirm this?
Yes I can. You are right that it could be problematic to use temporary memory for the Device description passed to GetDeviceFromDescription().

I typically only use that call to create a temporary CDevice object and then delete it after completing whatever needed to be done. If you need to keep the CDevice around for a while, make sure you use a variable for the description that will be around for the life of the object.

Good catch, but I probably won't change the API at this time since there is a workaround.