From bd1771bc665b26ca16540a3b69d10c79af80d8eb Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Sun, 16 Feb 2014 10:02:42 -0800 Subject: [PATCH] get rid of messy snprintf string concatenation --- src/caffe/util/insert_splits.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/caffe/util/insert_splits.cpp b/src/caffe/util/insert_splits.cpp index eaf1f23..9ced99b 100644 --- a/src/caffe/util/insert_splits.cpp +++ b/src/caffe/util/insert_splits.cpp @@ -3,11 +3,12 @@ #include #include #include +#include -#include "caffe/common.hpp" #include "caffe/util/insert_splits.hpp" using std::map; +using std::ostringstream; namespace caffe { @@ -88,11 +89,9 @@ string get_split_blob_name(const string& blob_name, const int split_index) { if (split_index == 0) { return blob_name; } - const int suffix_max_length = 16; - char split_suffix[suffix_max_length]; - CHECK_LT(snprintf(split_suffix, suffix_max_length, "_split_%d", split_index), - suffix_max_length); - return blob_name + split_suffix; + ostringstream split_blob_name; + split_blob_name << blob_name << "_split_" << split_index; + return split_blob_name.str(); } } // namespace caffe -- 2.7.4