From: Thomas Otto Date: Thu, 19 Mar 2020 21:47:51 +0000 (+0100) Subject: Adapt process_preprocessed_file() to use split_into_strings() X-Git-Tag: v4.0~547^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e79e524f90879d09815cebc3aba7536bb38c1e1f;p=thirdparty%2Fccache.git Adapt process_preprocessed_file() to use split_into_strings() --- diff --git a/src/ccache.cpp b/src/ccache.cpp index f93bc2f15..530f116d1 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -679,17 +679,14 @@ process_preprocessed_file(Context& ctx, ctx.ignore_headers = nullptr; ctx.ignore_headers_len = 0; + if (!ctx.config.ignore_headers_in_manifest().empty()) { - char *header, *p, *q, *saveptr = nullptr; - p = x_strdup(ctx.config.ignore_headers_in_manifest().c_str()); - q = p; - while ((header = strtok_r(q, PATH_DELIM, &saveptr))) { + for (const std::string& header : Util::split_into_strings( + ctx.config.ignore_headers_in_manifest(), PATH_DELIM)) { ctx.ignore_headers = static_cast(x_realloc( ctx.ignore_headers, (ctx.ignore_headers_len + 1) * sizeof(char*))); - ctx.ignore_headers[ctx.ignore_headers_len++] = x_strdup(header); - q = nullptr; + ctx.ignore_headers[ctx.ignore_headers_len++] = x_strdup(header.c_str()); } - free(p); } // Bytes between p and q are pending to be hashed.