[Developers] Re: Patch: [cctk_WarnLevel.h and WarnLevel.c]: to register the callbacks call them
Tom Goodale
goodale at cct.lsu.edu
Thu Jun 2 06:20:49 CDT 2005
Hi Jian,
the patch looks generally ok, I'd like a few things changed before I apply
it, 'though:
- Make the internal functions static, as they don't need to be in the
external namespace. Thus they will not appear in the header.
- Add a check if the appropriate callback list is NULL before generating
the string to be passed to the callback calling routine; this will
save time if there are no registered callbacks.
- Use Util_asprintf, rather than vsnprintf, as the latter is not
standard, and the former will prevent you needing to do an explicit
malloc. Don't forget to free the memory afterwards !
- Move the routines to the "external" and "internal" sections of the .c
file rather than generating a new section.
- Make the code conform to the coding guidelines - some of the
indentation is a bit odd. (Or did you accidently use tabs ?)
- Don't use macros to define all the arguments. You could provide a
couple of typedefs for the types of the callback functions instead as
a way to avoid repetition; there shouldn't be any need for #defines
for the arguments for the internal functions.
- Have comments as you would like them in the final version.
Cheers,
Tom
On Thu, 26 May 2005, Tom Goodale wrote:
>
> Hi Jian,
>
> thanks for this. I'll look through the patches, but as a first comment, the
> CCTKi functions can be static and so don't need to appear in the header file;
> they can also be void as they don't need to return an error code.
>
> Tom
>
> On Thu, 26 May 2005, Jian Tao wrote:
>
>> Hi,
>>
>> Four new functions are declared in cctk_WarnLevel.h together with the
>> macros
>> to enable users to register their own functions to take care of Info/Warn
>> message. The main purpose is to provide a generic interface to deal with
>> Info/Warn message.
>>
>> A sample thorn is also ready and was used to test the those four functions.
>>
>> Cheers,
>> Jian
>>
>> ###########################################################
>> int CCTK_WarnCallbackRegister(int minlevel,
>> int maxlevel,
>> void *data,
>> void
>> callback(CCTK_DECLARE_WARN_CALLBACK_ARGS));
>>
>> int CCTKi_WarnCallbacksCall(CCTKi_DECLARE_WARN_CALLBACKSCALL_ARGS);
>>
>> int CCTK_InfoCallbackRegister(/*int minlevel,
>> int maxlevel,*/
>> void *data,
>> void
>> callback(CCTK_DECLARE_INFO_CALLBACK_ARGS));
>>
>> int CCTKi_InfoCallbacksCall(CCTKi_DECLARE_INFO_CALLBACKSCALL_ARGS);
>> ###########################################################
>>
>>
> _______________________________________________
> Developers mailing list
> Developers at cactuscode.org
> http://www.cactuscode.org/mailman/listinfo/developers
>
More information about the Developers
mailing list