diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-03 12:53:40 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-03 12:55:22 +0200 |
commit | 19bf50bbff325024c2ed9ad724aeb6acb39bae39 (patch) | |
tree | 811b25f52c49c501e58604757e5c72d442210377 /src/utils/strprintf.cpp | |
parent | a8ebdf2555ac6b89afa2e0e575ba01c349ef3fe2 (diff) | |
download | mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.gz mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.bz2 mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.xz mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.zip |
Moved strprintf into stringutils.{h,cpp}
Diffstat (limited to 'src/utils/strprintf.cpp')
-rw-r--r-- | src/utils/strprintf.cpp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/utils/strprintf.cpp b/src/utils/strprintf.cpp deleted file mode 100644 index d960bc96..00000000 --- a/src/utils/strprintf.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The Mana World - * Copyright (C) 2007 The Mana World Development Team - * - * This file is part of The Mana World. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "utils/strprintf.h" - -#include <cstdarg> -#include <cstdio> - -std::string strprintf(char const *format, ...) -{ - char buf[256]; - va_list(args); - va_start(args, format); - int nb = vsnprintf(buf, 256, format, args); - va_end(args); - if (nb < 256) - { - return buf; - } - // The static size was not big enough, try again with a dynamic allocation. - ++nb; - char *buf2 = new char[nb]; - va_start(args, format); - vsnprintf(buf2, nb, format, args); - va_end(args); - std::string res(buf2); - delete [] buf2; - return res; -} |