X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcontext.cpp;h=b85a39abd92f6a19c53ef60e2bb3c7e2d0e77990;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=98c29f86c2cbac21f344e3a1df33231e6e6eb7c5;hpb=c9e313bc594f40a86eed237dce222c0fc99c957f;p=lttng-tools.git diff --git a/src/common/context.cpp b/src/common/context.cpp index 98c29f86c..b85a39abd 100644 --- a/src/common/context.cpp +++ b/src/common/context.cpp @@ -6,13 +6,14 @@ */ #include "context.hpp" -#include -#include + #include #include -int parse_application_context(const char *str, char **out_provider_name, - char **out_ctx_name) +#include +#include + +int parse_application_context(const char *str, char **out_provider_name, char **out_ctx_name) { const char app_ctx_prefix[] = "$app."; char *provider_name = NULL, *ctx_name = NULL; @@ -46,22 +47,20 @@ int parse_application_context(const char *str, char **out_provider_name, * No colon found or no ctx name ("$app.provider:") or no provider name * given ("$app.:..."), which is invalid. */ - if (!colon_pos || colon_pos == len || - colon_pos == sizeof(app_ctx_prefix)) { + if (!colon_pos || colon_pos == len || colon_pos == sizeof(app_ctx_prefix)) { goto not_found; } 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; } - strncpy(provider_name, str + sizeof(app_ctx_prefix) - 1, - provider_name_len - 1); + strncpy(provider_name, str + sizeof(app_ctx_prefix) - 1, provider_name_len - 1); 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; @@ -76,4 +75,3 @@ not_found: free(ctx_name); return -1; } -