Skip to content

Commit

Permalink
in_calyptia_fleet: generate_base_fleet_directory now allocates the fl…
Browse files Browse the repository at this point in the history
…b_sds_t for the caller.

Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Oct 11, 2023
1 parent 2dbf916 commit 632966a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,13 @@ struct reload_ctx {
flb_sds_t cfg_path;
};

static flb_sds_t generate_fleet_directory(struct flb_in_calyptia_fleet_config *ctx, flb_sds_t *fleet_dir)
static flb_sds_t generate_base_fleet_directory(struct flb_in_calyptia_fleet_config *ctx, flb_sds_t *fleet_dir)
{
*fleet_dir = flb_sds_create_size(4096);
if (*fleet_dir == NULL) {
return NULL;
}

if (ctx->fleet_name != NULL) {
return flb_sds_printf(fleet_dir, "%s" PATH_SEPARATOR "%s" PATH_SEPARATOR "%s",
ctx->config_dir, ctx->machine_id, ctx->fleet_name);
Expand Down Expand Up @@ -1082,12 +1087,7 @@ static int calyptia_config_delete_old(struct flb_in_calyptia_fleet_config *ctx)
flb_sds_t glob_ini;
int idx;

glob_ini = flb_sds_create_size(128);
if (glob_ini == NULL) {
return -1;
}

if (generate_fleet_directory(ctx, &glob_ini) == NULL) {
if (generate_base_fleet_directory(ctx, &glob_ini) == NULL) {
flb_sds_destroy(glob_ini);
return -1;
}
Expand All @@ -1111,6 +1111,7 @@ static int calyptia_config_delete_old(struct flb_in_calyptia_fleet_config *ctx)
unlink(inis->entries[idx]->data.as_string);
}

flb_sds_destroy(glob_ini);
return 0;
}

Expand Down Expand Up @@ -1339,9 +1340,7 @@ static int create_fleet_directory(struct flb_in_calyptia_fleet_config *ctx)
}
}

myfleetdir = flb_sds_create_size(256);

if (generate_fleet_directory(ctx, &myfleetdir) == NULL) {
if (generate_base_fleet_directory(ctx, &myfleetdir) == NULL) {
flb_sds_destroy(myfleetdir);
return -1;
}
Expand Down

0 comments on commit 632966a

Please sign in to comment.