diff options
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_executor.cc | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc | 25 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc | 13 |
3 files changed, 22 insertions, 22 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index a8d0bc1c8..b3f987f72 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -29,6 +29,7 @@ #include <gr_block_detail.h> #include <gr_buffer.h> #include <boost/thread.hpp> +#include <boost/format.hpp> #include <iostream> #include <limits> #include <assert.h> @@ -165,9 +166,8 @@ gr_block_executor::gr_block_executor (gr_block_sptr block) : d_block(block), d_log(0) { if (ENABLE_LOGGING){ - char name[100]; - snprintf(name, sizeof(name), "sst-%03d.log", which_scheduler++); - d_log = new std::ofstream(name); + std::string name = str(boost::format("sst-%03d.log") % which_scheduler++); + d_log = new std::ofstream(name.c_str()); std::unitbuf(*d_log); // make it unbuffered... *d_log << "gr_block_executor: " << d_block << std::endl; diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc index 3b8a6e617..7138605c9 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc @@ -30,6 +30,8 @@ #include <stdio.h> #include <string.h> #include <gr_local_sighandler.h> +#include <vector> +#include <boost/format.hpp> // all the factories we know about #include <gr_vmcircbuf_createfilemapping.h> @@ -130,7 +132,7 @@ init_buffer (gr_vmcircbuf *c, int counter, int size) } static bool -check_mapping (gr_vmcircbuf *c, int counter, int size, char *msg, bool verbose) +check_mapping (gr_vmcircbuf *c, int counter, int size, const char *msg, bool verbose) { bool ok = true; @@ -163,28 +165,28 @@ check_mapping (gr_vmcircbuf *c, int counter, int size, char *msg, bool verbose) return ok; } -static char * +static const char * memsize (int size) { - static char buf[100]; + static std::string buf; if (size >= (1 << 20)){ - snprintf (buf, sizeof (buf), "%dMB", size / (1 << 20)); + buf = str(boost::format("%dMB") % (size / (1 << 20))); } else if (size >= (1 << 10)){ - snprintf (buf, sizeof (buf), "%dKB", size / (1 << 10)); + buf = str(boost::format("%dKB") % (size / (1 << 10))); } else { - snprintf (buf, sizeof (buf), "%d", size); + buf = str(boost::format("%d") % size); } - return buf; + return buf.c_str(); } static bool test_a_bunch (gr_vmcircbuf_factory *factory, int n, int size, int *start_ptr, bool verbose) { bool ok = true; - int counter[n]; - gr_vmcircbuf *c[n]; + std::vector<int> counter(n); + std::vector<gr_vmcircbuf *> c(n); int cum_size = 0; for (int i = 0; i < n; i++){ @@ -202,9 +204,8 @@ test_a_bunch (gr_vmcircbuf_factory *factory, int n, int size, int *start_ptr, bo } for (int i = 0; i < n; i++){ - char msg[100]; - snprintf (msg, sizeof (msg), "test_a_bunch_%dx%s[%d]", n, memsize (size), i); - ok &= check_mapping (c[i], counter[i], size, msg, verbose); + std::string msg = str(boost::format("test_a_bunch_%dx%s[%d]") % n % memsize (size) % i); + ok &= check_mapping (c[i], counter[i], size, msg.c_str(), verbose); } for (int i = 0; i < n; i++){ diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc index 42c459484..1b4d9700a 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc @@ -37,6 +37,7 @@ #include <stdio.h> #include <gr_pagesize.h> #include <gr_vmcircbuf_createfilemapping.h> +#include <boost/format.hpp> #ifdef HAVE_CREATEFILEMAPPING // Print Windows error (could/should be global?) @@ -72,23 +73,21 @@ gr_vmcircbuf_createfilemapping::gr_vmcircbuf_createfilemapping (int size) throw std::runtime_error ("gr_vmcircbuf_createfilemapping"); } - char seg_name[1024]; - snprintf (seg_name, sizeof (seg_name), "/gnuradio-%d-%d", getpid (), s_seg_counter); + std::string seg_name = str(boost::format("/gnuradio-%d-%d") % getpid () % s_seg_counter); d_handle = CreateFileMapping(INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // max. object size size, // buffer size - seg_name); // name of mapping object + seg_name.c_str()); // name of mapping object s_seg_counter++; if (d_handle == NULL || d_handle == INVALID_HANDLE_VALUE){ - char msg[1024]; - snprintf( msg, sizeof(msg), - "gr_vmcircbuf_mmap_createfilemapping: CreateFileMapping [%s]", + std::string msg = str(boost::format( + "gr_vmcircbuf_mmap_createfilemapping: CreateFileMapping [%s]") % seg_name ); - werror( msg, GetLastError() ); + werror((char *) msg.c_str(), GetLastError() ); throw std::runtime_error ("gr_vmcircbuf_mmap_createfilemapping"); } |