mirror of
https://github.com/coderkei/akmenu-next.git
synced 2025-06-19 17:35:38 -04:00
24 lines
492 B
C++
24 lines
492 B
C++
/*
|
|
Copyright (C) 2007 Acekard, www.acekard.com
|
|
|
|
SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "stringtool.h"
|
|
#include <malloc.h>
|
|
#include <cstdarg>
|
|
#include <cstdio>
|
|
|
|
std::string formatString(const char* fmt, ...) {
|
|
const char* f = fmt;
|
|
va_list argList;
|
|
va_start(argList, fmt);
|
|
char* ptempStr = NULL;
|
|
size_t max_len = vasiprintf(&ptempStr, f, argList);
|
|
std::string str(ptempStr);
|
|
str.resize(max_len);
|
|
free(ptempStr);
|
|
va_end(argList);
|
|
return str;
|
|
}
|