|
40 | 40 | #ifndef __wur |
41 | 41 | # define __wur |
42 | 42 | #endif |
| 43 | +// malloc and free assignments |
| 44 | +#ifndef __attr_dealloc |
| 45 | +# define __attr_dealloc(dealloc, argno) |
| 46 | +# define __attr_dealloc_free |
| 47 | +#endif |
| 48 | +#ifndef __attribute_malloc__ |
| 49 | +# define __attribute_malloc__ |
| 50 | +#endif |
43 | 51 |
|
44 | 52 | #include <audit_logging.h> |
45 | 53 |
|
@@ -281,24 +289,24 @@ int audit_delete_rule_data(int fd, struct audit_rule_data *rule, |
281 | 289 | int flags, int action); |
282 | 290 |
|
283 | 291 | /* Rule-building helper functions */ |
| 292 | +/* Deallocates the audit_rule_rule object, and any associated resources */ |
| 293 | +void audit_rule_free_data(struct audit_rule_data *rule); |
284 | 294 | /* Heap-allocates and initializes an audit_rule_data */ |
285 | | -struct audit_rule_data *audit_rule_create_data(void); |
| 295 | +struct audit_rule_data *audit_rule_create_data(void) |
| 296 | + __attribute_malloc__ __attr_dealloc (audit_rule_free_data, 1); |
286 | 297 | /* Initializes an existing audit_rule_data struct */ |
287 | 298 | void audit_rule_init_data(struct audit_rule_data *rule); |
288 | 299 | int audit_rule_syscallbyname_data(struct audit_rule_data *rule, |
289 | 300 | const char *scall); |
290 | 301 | int audit_rule_io_uringbyname_data(struct audit_rule_data *rule, |
291 | 302 | const char *scall); |
292 | 303 |
|
293 | | -/* Note that the following function takes a **, where audit_rule_fieldpair() |
294 | | - * takes just a *. That structure may need to be reallocated as a result of |
295 | | - * adding new fields */ |
| 304 | +/* Note that the following function takes a **. That structure may need |
| 305 | + * to be reallocated as a result of adding new fields */ |
296 | 306 | int audit_rule_fieldpair_data(struct audit_rule_data **rulep, |
297 | 307 | char *pair, int flags); |
298 | 308 | int audit_rule_interfield_comp_data(struct audit_rule_data **rulep, |
299 | 309 | char *pair, int flags); |
300 | | -/* Deallocates the audit_rule_rule object, and any associated resources */ |
301 | | -void audit_rule_free_data(struct audit_rule_data *rule); |
302 | 310 |
|
303 | 311 | /* Capability testing functions */ |
304 | 312 | int audit_can_control(void); |
|
0 commit comments