X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dccf1b41e9c7b5a696f01abceaa2779fe65f154f..67d66b0cf79b9fc02c0450f254584693dbf21d3b:/src/xbt/string.cpp diff --git a/src/xbt/string.cpp b/src/xbt/string.cpp index f23e4295ff..7468c3b095 100644 --- a/src/xbt/string.cpp +++ b/src/xbt/string.cpp @@ -1,23 +1,21 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-2021. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include - -#include - +#include #include #include +#include +#include + namespace simgrid { namespace xbt { -#if HAVE_MC +#if SIMGRID_HAVE_MC -const char string::NUL = '\0'; +char string::NUL = '\0'; #endif @@ -28,14 +26,13 @@ std::string string_vprintf(const char *fmt, va_list ap) va_copy(ap2, ap); int size = std::vsnprintf(nullptr, 0, fmt, ap2); va_end(ap2); - if (size < 0) - xbt_die("string_vprintf error"); + xbt_assert(size >= 0, "string_vprintf error"); // Allocate the string and format: std::string res; res.resize(size); - if (size != 0 && std::vsnprintf(&res[0], size + 1, fmt, ap) != size) - xbt_die("string_vprintf error"); + if (size != 0) + xbt_assert(std::vsnprintf(&res[0], size + 1, fmt, ap) == size, "string_vprintf error"); return res; }