X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fadd_context.cpp;fp=src%2Fbin%2Flttng%2Fcommands%2Fadd_context.cpp;h=b25d2d10a3aced9b771a8094bac5e12cf3bee335;hp=27d932c340ab8622225df5badd8ca1d99e5b3cce;hb=64803277bbdbe0a943360d918298a48157d9da55;hpb=60f1b42d6280b6bd386abb726dca4fd3b31d8491 diff --git a/src/bin/lttng/commands/add_context.cpp b/src/bin/lttng/commands/add_context.cpp index 27d932c34..b25d2d10a 100644 --- a/src/bin/lttng/commands/add_context.cpp +++ b/src/bin/lttng/commands/add_context.cpp @@ -902,21 +902,21 @@ void destroy_ctx_type(struct ctx_type *type) if (type->opt) { free(type->opt->symbol); } - free(type->opt); + delete type->opt; free(type); } static struct ctx_type *create_ctx_type(void) { - struct ctx_type *type = (ctx_type *) zmalloc(sizeof(*type)); + struct ctx_type *type = zmalloc(); if (!type) { PERROR("malloc ctx_type"); goto end; } - type->opt = (struct ctx_opts *) zmalloc(sizeof(*type->opt)); + type->opt = new struct ctx_opts; if (!type->opt) { PERROR("malloc ctx_type options"); destroy_ctx_type(type); @@ -1091,7 +1091,7 @@ struct ctx_type *get_context_type(const char *ctx) } provider_name_len = colon_pos - sizeof(app_ctx_prefix) + 2; - provider_name = (char *) zmalloc(provider_name_len); + provider_name = calloc(provider_name_len); if (!provider_name) { PERROR("malloc provider_name"); goto not_found; @@ -1101,7 +1101,7 @@ struct ctx_type *get_context_type(const char *ctx) type->opt->u.app_ctx.provider_name = provider_name; ctx_name_len = len - colon_pos; - ctx_name = (char *) zmalloc(ctx_name_len); + ctx_name = calloc(ctx_name_len); if (!ctx_name) { PERROR("malloc ctx_name"); goto not_found;