diff options
author | Sam James <sam@gentoo.org> | 2022-03-31 08:27:42 +0100 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2022-05-08 14:56:26 -0500 |
commit | 7b2e8f9efd28566133b0da5ccf91b0e24a0d6c15 (patch) | |
tree | fbd03f747b1709cff63fa7edcdc557ec4f2a1c75 /src/librc | |
parent | 000a2c19b43afb60559cbf63b71446f6c908505a (diff) |
librc: mark rc_deptree_* functions as mallocs
(This is analogous to the rc_stringlist change.)
This gives a hint to the compiler that allocations (return values)
from this function should be paired with a corresponding dealloc/free
function.
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'src/librc')
-rw-r--r-- | src/librc/librc-depend.c | 2 | ||||
-rw-r--r-- | src/librc/rc.h.in | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c index e240cba0..4da81c03 100644 --- a/src/librc/librc-depend.c +++ b/src/librc/librc-depend.c @@ -76,6 +76,8 @@ rc_deptree_free(RC_DEPTREE *deptree) free(di); di = di2; } + + /* Use free() here since rc_deptree_free should not call itself */ free(deptree); } diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index 0727c12e..69d9d0e4 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -407,6 +407,10 @@ bool rc_older_than(const char *, const char *, time_t *, char *); * @return pointer to the value, otherwise NULL */ char *rc_proc_getent(const char *); +/*! Free a deptree and its information + * @param deptree to free */ +void rc_deptree_free(RC_DEPTREE *); + /*! Update the cached dependency tree if it's older than any init script, * its configuration file or an external configuration file the init script * has specified. @@ -426,11 +430,17 @@ bool rc_deptree_update_needed(time_t *, char *); /*! Load the cached dependency tree and return a pointer to it. * This pointer should be freed with rc_deptree_free when done. * @return pointer to the dependency tree */ +#ifdef HAVE_MALLOC_EXTENDED_ATTRIBUTE +__attribute__ ((malloc (rc_deptree_free, 1))) +#endif RC_DEPTREE *rc_deptree_load(void); /*! Load a cached dependency tree from the specified file and return a pointer * to it. This pointer should be freed with rc_deptree_free when done. * @return pointer to the dependency tree */ +#ifdef HAVE_MALLOC_EXTENDED_ATTRIBUTE +__attribute__ ((malloc (rc_deptree_free, 1))) +#endif RC_DEPTREE *rc_deptree_load_file(const char *); /*! List the depend for the type of service @@ -459,10 +469,6 @@ RC_STRINGLIST *rc_deptree_depends(const RC_DEPTREE *, const RC_STRINGLIST *, * @return NULL terminated list of services in order */ RC_STRINGLIST *rc_deptree_order(const RC_DEPTREE *, const char *, int); -/*! Free a deptree and its information - * @param deptree to free */ -void rc_deptree_free(RC_DEPTREE *); - /*! @name Plugins * For each plugin loaded we will call rc_plugin_hook with the below * enum and either the runlevel name or service name. |