65 lines
1.1 KiB
C++
Raw Normal View History

2024-01-08 23:37:00 +08:00
2024-04-02 15:36:52 +08:00
#include "define.h"
void free_all(void *str)
{
delete str;
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
void freewstringlist(wchar_t **strlist, int num)
{
for (int i = 0; i < num; i++)
{
delete strlist[i];
}
delete strlist;
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
void freestringlist(char **strlist, int num)
{
for (int i = 0; i < num; i++)
{
delete strlist[i];
}
delete strlist;
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
int *vecint2c(std::vector<int> &vs)
{
int *argv = new int[vs.size() + 1];
for (size_t i = 0; i < vs.size(); i++)
{
argv[i] = vs[i];
}
return argv;
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
char **vecstr2c(std::vector<std::string> &vs)
{
char **argv = new char *[vs.size() + 1];
2024-01-08 23:37:00 +08:00
2024-04-02 15:36:52 +08:00
for (size_t i = 0; i < vs.size(); i++)
{
argv[i] = new char[vs[i].size() + 1];
strcpy_s(argv[i], vs[i].size() + 1, vs[i].c_str());
argv[i][vs[i].size()] = 0;
}
return argv;
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
wchar_t **vecwstr2c(std::vector<std::wstring> &vs)
{
wchar_t **argv = new wchar_t *[vs.size() + 1];
2024-01-08 23:37:00 +08:00
2024-04-02 15:36:52 +08:00
for (size_t i = 0; i < vs.size(); i++)
{
argv[i] = new wchar_t[vs[i].size() + 1];
wcscpy_s(argv[i], vs[i].size() + 1, vs[i].c_str());
argv[i][vs[i].size()] = 0;
}
return argv;
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
void c_free(void *ptr)
{
free(ptr);
2024-03-05 04:15:50 +08:00
}