Have to memset AEECallbacks before use? | developer.brewmp.com Have to memset AEECallbacks before use? | developer.brewmp.com

Developer

Have to memset AEECallbacks before use?

Forums:

I have been writing some code that uses IWEB, using the RoadWarrior example for inspiration.

I was making requests by calling CALLBACK_Init() on a callback and then calling IWEB_GetResponse() but when I did this GetResponse would crash unless the callback was allocated statically. The difference turns out to be that my static variables are prefilled with 0s while my heap variables are not. If I memset the callback to 0s before calling CALLBACK_Init() then things work fine.

Why is this necessary? I would have expected CALLBACK_Init to be responsible for all required clearing.

Is this documented somehwhere? I couldn't find it mentioned in the BREW API Reference.

Is roadwarrior.c relying on good luck to get its callback cleared?

The RoadWarrior app is calling MEMSET on the AEECallback object. Note the following code near the beginning of InitAppData():
MEMSET(((char*)pMe) + sizeof(AEEApplet), 0, sizeof(*pMe) - sizeof(AEEApplet));
It is not really necessary to zero out the entire AEECallback object, but it is important to set AEECallback.pfnCancel = NULL before you start using the object.
Please see the API Reference under ISHELL_Resume() for more details.

The RoadWarrior app is calling MEMSET on the AEECallback object. Note the following code near the beginning of InitAppData():
MEMSET(((char*)pMe) + sizeof(AEEApplet), 0, sizeof(*pMe) - sizeof(AEEApplet));
It is not really necessary to zero out the entire AEECallback object, but it is important to set AEECallback.pfnCancel = NULL before you start using the object.
Please see the API Reference under ISHELL_Resume() for more details.

Thanks for the response. I stand corrected on the call to memset in roadwarrior.
I am confused about how I could have known to read the reference entry for ISHELL_Resume, though. Starting with the page for IWEB_GetResponse it is easy to see that CALLBACK_* methods are useful to read about but I cannot see any reference to ISHELL_Resume from CALLBACK_Init. How can I avoid this problem in the future?

Thanks for the response. I stand corrected on the call to memset in roadwarrior.
I am confused about how I could have known to read the reference entry for ISHELL_Resume, though. Starting with the page for IWEB_GetResponse it is easy to see that CALLBACK_* methods are useful to read about but I cannot see any reference to ISHELL_Resume from CALLBACK_Init. How can I avoid this problem in the future?

No problem. The link to ISHELL_Resume() isn't directly listed. However, there is a link to AEECallback in CALLBACK_Init() and AEECallback links to ISHELL_Resume()
Other than the 'See Also' section, you should also follow the links embedded within the help text.

No problem. The link to ISHELL_Resume() isn't directly listed. However, there is a link to AEECallback in CALLBACK_Init() and AEECallback links to ISHELL_Resume()
Other than the 'See Also' section, you should also follow the links embedded within the help text.