fix memory leaks

This commit is contained in:
2024-10-27 19:43:05 +00:00
parent a86291ca75
commit 87d8767d11
9 changed files with 236 additions and 35 deletions

View File

@@ -16,6 +16,27 @@ struct b_command_arg *b_command_arg_create(void)
return out;
}
void b_command_arg_destroy(struct b_command_arg *arg)
{
if (arg->arg_name) {
free(arg->arg_name);
}
if (arg->arg_description) {
free(arg->arg_description);
}
if (arg->arg_allowed_values) {
for (unsigned int i = 0; arg->arg_allowed_values[i]; i++) {
free(arg->arg_allowed_values[i]);
}
free(arg->arg_allowed_values);
}
free(arg);
}
b_status b_command_arg_set_name(struct b_command_arg *arg, const char *name)
{
char *n = b_strdup(name);