Skip to content

Commit 278d1dc

Browse files
committed
Fix conversion from string_view to string
1 parent 1cdd3ca commit 278d1dc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

alc/backends/oss.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class FileHandle {
121121
~FileHandle() { if(mFd != -1) ::close(mFd); }
122122

123123
template<typename ...Args>
124-
[[nodiscard]] auto open(const char *fname, Args&& ...args) -> bool
124+
[[nodiscard]] auto open(gsl::czstring const fname, Args&& ...args) -> bool
125125
{
126126
close();
127127
mFd = ::open(fname, std::forward<Args>(args)...);
@@ -149,21 +149,25 @@ void ALCossListAppend(std::vector<DevMap> &list, std::string_view handle, std::s
149149
if(strncmp(path.data() + i, handle.data() + hoffset, path.size() - i) == 0)
150150
handle = handle.substr(0, hoffset);
151151
path = path.substr(0, i);
152+
break;
152153
}
153154
}
154155
#endif
155-
if(handle.empty())
156-
handle = path;
156+
if(path.empty())
157+
return;
157158

158159
if(std::ranges::find(list, path, &DevMap::device_name) != list.end())
159160
return;
160161

162+
if(handle.empty())
163+
handle = path;
164+
161165
auto count = 1;
162166
auto newname = std::string{handle};
163167
while(std::ranges::find(list, newname, &DevMap::name) != list.end())
164168
newname = al::format("{} #{}", handle, ++count);
165169

166-
const auto &entry = list.emplace_back(std::move(newname), path);
170+
const auto &entry = list.emplace_back(std::move(newname), std::string{path});
167171
TRACE("Got device \"{}\", \"{}\"", entry.name, entry.device_name);
168172
}
169173

0 commit comments

Comments
 (0)