68 lines
1.3 KiB
C++
Raw Normal View History

2024-04-02 15:36:52 +08:00
#include "define.h"
2024-01-08 23:37:00 +08:00
2024-04-02 15:36:52 +08:00
void free_all(void *str)
{
2024-01-08 23:37:00 +08:00
delete str;
}
2024-04-02 15:36:52 +08:00
void freewstringlist(wchar_t **strlist, int num)
{
for (int i = 0; i < num; i++)
{
2024-01-08 23:37:00 +08:00
delete strlist[i];
}
delete strlist;
}
2024-04-02 15:36:52 +08:00
void freestringlist(char **strlist, int num)
{
for (int i = 0; i < num; i++)
{
2024-01-08 23:37:00 +08:00
delete strlist[i];
}
delete strlist;
}
2024-04-02 15:36:52 +08:00
void freeocrres(ocrres res, int num)
{
freewstringlist(res.lines, num);
2024-01-08 23:37:00 +08:00
delete res.xs;
delete res.ys;
delete res.xs2;
delete res.ys2;
}
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];
2024-01-08 23:37:00 +08:00
}
return argv;
}
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++)
{
2024-01-08 23:37:00 +08:00
argv[i] = new char[vs[i].size() + 1];
2024-04-02 15:36:52 +08:00
strcpy_s(argv[i], vs[i].size() + 1, vs[i].c_str());
2024-01-08 23:37:00 +08:00
argv[i][vs[i].size()] = 0;
}
return argv;
}
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++)
{
2024-01-08 23:37:00 +08:00
argv[i] = new wchar_t[vs[i].size() + 1];
2024-04-02 15:36:52 +08:00
wcscpy_s(argv[i], vs[i].size() + 1, vs[i].c_str());
2024-01-08 23:37:00 +08:00
argv[i][vs[i].size()] = 0;
}
return argv;
}