diff options
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; -} |