little issue in plugin API

Having problems? Maybe others have had the same problem too. Post HouseBot technical issues here.
Post Reply
peter
Member
Posts: 35
Joined: Wed May 31, 2006 3:51 am
Location: Berlin , GER

little issue in plugin API

Post 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
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: little issue in plugin API

Post 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.
Scott
Post Reply