This may seem a bit backwards: we take nice C++ list<string> and do the
C dance. It's a bit defensive: this class is used in the segv handler
(in the backtrace() and backtrace_symbol() path), so we want to minimize
the work we do on the heap in that case. (For the list<string> path,
we can do whatever we like.)
Signed-off-by: Sage Weil <sage@newdream.net>
#endif
#include <stdlib.h>
+#include <list>
+#include <string>
+
namespace ceph {
class Formatter;
size_t size;
char **strings;
+ std::list<std::string> src_strings;
+
+ explicit BackTrace(std::list<std::string>& s)
+ : skip(0),
+ size(s.size()) {
+ src_strings = s;
+ strings = (char **)malloc(sizeof(*strings) * src_strings.size());
+ unsigned i = 0;
+ for (auto& s : src_strings) {
+ strings[i++] = (char *)s.c_str();
+ }
+ }
explicit BackTrace(int s) : skip(s) {
#ifdef HAVE_EXECINFO_H
size = backtrace(array, max);