Skip to content

Introduce __attribute__((cleanup)) for memory management.#20

Open
kivkiv12345 wants to merge 1 commit intomasterfrom
__attribute__((cleanup))
Open

Introduce __attribute__((cleanup)) for memory management.#20
kivkiv12345 wants to merge 1 commit intomasterfrom
__attribute__((cleanup))

Conversation

@kivkiv12345
Copy link
Contributor

This commit makes us more dependant on GCC,
but introduces a more reliable way to free optparse_t pointers.

Currently this pull request solves the following memory leaks:

2 missing calls to optparse_del() in loki.c (loki_start_cmd())
6 missing calls to optparse_del() in slash_apm.c (apm_load_cmd(), apm_info_cmd())
1 call to optparse_del() after return in prometheus.c (prometheus_start_cmd())

1 missing call to optparse_del() in builtins.c (slash_builtin_watch())

csp_init_cmd() has been spared, as we deliberately leak "parser" there to keep some string pointers.

This commit makes us more dependant on GCC,
but introduces a more reliable way to free optparse_t pointers.

This commit also solves the following memory leaks:

2 missing calls to optparse_del() in loki.c (loki_start_cmd())
6 missing calls to optparse_del() in slash_apm.c (apm_load_cmd(), apm_info_cmd())
1 call to optparse_del() after return in prometheus.c (prometheus_start_cmd())

1 missing call to optparse_del() in builtins.c (slash_builtin_watch())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant