Skip to content

Commit

Permalink
Fix buffer size calculation in resolve_streams and resolve_stream fun…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
morningf authored and cboulay committed May 24, 2024
1 parent a9da358 commit e0dac29
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/lsl_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ class stream_outlet {
*/
inline std::vector<stream_info> resolve_streams(double wait_time = 1.0) {
lsl_streaminfo buffer[1024];
int nres = check_error(lsl_resolve_all(buffer, sizeof(buffer), wait_time));
int nres = check_error(lsl_resolve_all(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), wait_time));
return std::vector<stream_info>(&buffer[0], &buffer[nres]);
}

Expand All @@ -843,7 +843,7 @@ inline std::vector<stream_info> resolve_stream(const std::string &prop, const st
int32_t minimum = 1, double timeout = FOREVER) {
lsl_streaminfo buffer[1024];
int nres = check_error(
lsl_resolve_byprop(buffer, sizeof(buffer), prop.c_str(), value.c_str(), minimum, timeout));
lsl_resolve_byprop(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), prop.c_str(), value.c_str(), minimum, timeout));
return std::vector<stream_info>(&buffer[0], &buffer[nres]);
}

Expand All @@ -865,7 +865,7 @@ inline std::vector<stream_info> resolve_stream(
const std::string &pred, int32_t minimum = 1, double timeout = FOREVER) {
lsl_streaminfo buffer[1024];
int nres =
check_error(lsl_resolve_bypred(buffer, sizeof(buffer), pred.c_str(), minimum, timeout));
check_error(lsl_resolve_bypred(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), pred.c_str(), minimum, timeout));
return std::vector<stream_info>(&buffer[0], &buffer[nres]);
}

Expand Down

0 comments on commit e0dac29

Please sign in to comment.