Skip to content

Commit

Permalink
shared: Move cleanup attribute
Browse files Browse the repository at this point in the history
Move to macro.h where other attributes are located. The inline helper
function can also move along as we don't need to keep it separate.

Signed-off-by: Lucas De Marchi <[email protected]>
Link: #233
  • Loading branch information
lucasdemarchi committed Nov 12, 2024
1 parent f8ed5ee commit f94b5c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 8 additions & 1 deletion shared/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@
#define _must_check_ __attribute__((warn_unused_result))
#define _printf_format_(a, b) __attribute__((format(printf, a, b)))
#define _always_inline_ __inline__ __attribute__((always_inline))
#define _cleanup_(x) __attribute__((cleanup(x)))
#define _nonnull_(...) __attribute__((nonnull(__VA_ARGS__)))
#define _nonnull_all_ __attribute__((nonnull))

#define _cleanup_(x) __attribute__((cleanup(x)))

static inline void freep(void *p)
{
free(*(void **)p);
}
#define _cleanup_free_ _cleanup_(freep)

/* Define C11 noreturn without <stdnoreturn.h> and even on older gcc
* compiler versions */
#ifndef noreturn
Expand Down
5 changes: 0 additions & 5 deletions shared/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ static _always_inline_ unsigned int ALIGN_POWER2(unsigned int u)

/* misc */
/* ************************************************************************ */
static inline void freep(void *p)
{
free(*(void **)p);
}
#define _cleanup_free_ _cleanup_(freep)

static inline bool uadd32_overflow(uint32_t a, uint32_t b, uint32_t *res)
{
Expand Down

0 comments on commit f94b5c4

Please sign in to comment.