Skip to content

Commit

Permalink
Switch std::string::c_str() to C++11 std::string::data()
Browse files Browse the repository at this point in the history
  • Loading branch information
tstenner committed May 11, 2021
1 parent aa5309c commit ec58588
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/lsl_inlet_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ LIBLSL_C_API double lsl_pull_sample_str(
if (ec) *ec = lsl_internal_error;
return 0.0;
}
memcpy(buffer[k], tmp[k].c_str(), tmp[k].size());
memcpy(buffer[k], tmp[k].data(), tmp[k].size());
buffer[k][tmp[k].size()] = '\0';
}
return result;
Expand Down Expand Up @@ -219,7 +219,7 @@ LIBLSL_C_API unsigned long lsl_pull_chunk_str(lsl_inlet in, char **data_buffer,
if (ec) *ec = lsl_internal_error;
return 0;
}
memcpy(data_buffer[k], tmp[k].c_str(), tmp[k].size());
memcpy(data_buffer[k], tmp[k].data(), tmp[k].size());
data_buffer[k][tmp[k].size()] = '\0';
}
return result;
Expand Down Expand Up @@ -248,7 +248,7 @@ LIBLSL_C_API unsigned long lsl_pull_chunk_buf(lsl_inlet in, char **data_buffer,
return 0;
}
lengths_buffer[k] = (uint32_t)tmp[k].size();
memcpy(data_buffer[k], tmp[k].c_str(), tmp[k].size());
memcpy(data_buffer[k], tmp[k].data(), tmp[k].size());
data_buffer[k][tmp[k].size()] = '\0';
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/lsl_streaminfo_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ LIBLSL_C_API char *lsl_get_xml(lsl_streaminfo info) {
LOG_F(ERROR, "Error allocating memory for xmlinfo");
return nullptr;
}
memcpy(result, tmp.c_str(), tmp.size());
memcpy(result, tmp.data(), tmp.size());
result[tmp.size()] = '\0';
return result;
} catch (std::exception &e) {
Expand Down

0 comments on commit ec58588

Please sign in to comment.