mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
fix: declare alloc_c_string before use in c++ wrapper
This commit is contained in:
@@ -31,12 +31,6 @@ static inline std::optional<std::string> to_cpp_string(const char* psz)
|
||||
return psz == nullptr ? std::optional<std::string>("") : std::optional<std::string>(psz);
|
||||
}
|
||||
|
||||
static inline char* alloc_c_string(const std::optional<std::string>& str)
|
||||
{
|
||||
if (!str.has_value()) { return nullptr; }
|
||||
return alloc_c_string(str.value());
|
||||
}
|
||||
|
||||
static inline char* alloc_c_string(const std::string& str)
|
||||
{
|
||||
char* result = new char[str.size() + 1]; // +1 for null-terminator
|
||||
@@ -49,6 +43,12 @@ static inline char* alloc_c_string(const std::string& str)
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline char* alloc_c_string(const std::optional<std::string>& str)
|
||||
{
|
||||
if (!str.has_value()) { return nullptr; }
|
||||
return alloc_c_string(str.value());
|
||||
}
|
||||
|
||||
static inline void free_c_string(char* str)
|
||||
{
|
||||
delete[] str;
|
||||
|
||||
Reference in New Issue
Block a user