improve tools/common

This commit is contained in:
lixianjing 2023-07-06 15:36:18 +08:00
parent bbe3e23cdf
commit e4de55ebff
4 changed files with 32 additions and 31 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2023/07/06
* 完善tools/common。
2023/07/05
* 完善serial helper的文档(感谢俊杰提供补丁)。
* 完善资源生成脚本(感谢智明提供补丁)。

View File

@ -1,4 +1,32 @@
#include "common/utils.h"
#include "tkc.h"
wchar_t** argvw_create(int argc, char* argv[]) {
int i = 0;
wstr_t str;
wchar_t** argvw = (wchar_t**)TKMEM_ALLOC((argc + 1) * sizeof(wchar_t*));
return_value_if_fail(argvw != NULL, NULL);
wstr_init(&str, 100);
for (i = 0; i < argc; i++) {
wstr_set_utf8(&str, argv[i]);
argvw[i] = wcs_dup(str.str);
}
argvw[i] = NULL;
return argvw;
}
ret_t argvw_destroy(wchar_t** argvw) {
uint32_t i = 0;
return_value_if_fail(argvw != NULL, RET_BAD_PARAMS);
for (i = 0; argvw[i] != NULL; i++) {
TKMEM_FREE(argvw[i]);
}
TKMEM_FREE(argvw);
return RET_OK;
}
#if !defined(WIN32) || defined(MINGW)
int main(int argc, char* argv[]) {

View File

@ -315,30 +315,3 @@ const char* filter_name(char* name) {
return name;
}
wchar_t** argvw_create(int argc, char* argv[]) {
int i = 0;
wstr_t str;
wchar_t** argvw = TKMEM_ALLOC((argc + 1) * sizeof(wchar_t*));
return_value_if_fail(argvw != NULL, NULL);
wstr_init(&str, 100);
for (i = 0; i < argc; i++) {
wstr_set_utf8(&str, argv[i]);
argvw[i] = wcs_dup(str.str);
}
argvw[i] = NULL;
return argvw;
}
ret_t argvw_destroy(wchar_t** argvw) {
uint32_t i = 0;
return_value_if_fail(argvw != NULL, RET_BAD_PARAMS);
for (i = 0; argvw[i] != NULL; i++) {
TKMEM_FREE(argvw[i]);
}
TKMEM_FREE(argvw);
return RET_OK;
}

View File

@ -54,9 +54,6 @@ const char* get_next_token(const char* p, char* token, char c);
const char* filter_name(char* name);
wchar_t** argvw_create(int argc, char* argv[]);
ret_t argvw_destroy(wchar_t** argvw);
END_C_DECLS
#endif // UTILS_H