emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __attribute__ ((cleanup)) and emacs-module.c


From: Paul Eggert
Subject: Re: __attribute__ ((cleanup)) and emacs-module.c
Date: Sat, 11 Mar 2023 13:21:16 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1

On 2023-03-10 17:37, Po Lu wrote:

+#define MODULE_INTERNAL_CLEANUP                        \
+  module_reset_handlerlist (&internal_cleanup)

No need for the "&" here. Omit it, and change the type of module_reset_handlerlist to take 'struct handler *' instead of 'struct handler **'.

Also, please make this macro a parameterless function-style macro called via 'MODULE_INTERNAL_CLEANUP ()' as it acts like a function.

Also, please define a macro MODULE_FUNCTION_END something like this:

  #define MODULE_FUNCTION_END(retval) \
     (MODULE_INTERNAL_CLEANUP (), retval)

and use 'return MODULE_FUNCTION_END (<simple-expression>);' when the cleanup is immediately followed by a return of a value of a simple expression. For complex expressions that can throw exceptions, you can use something like:

    <type> r = <complex-expression>;
    return MODULE_FUNCTION_END (r);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]