| 350 | } |
| 351 | |
| 352 | static int copy_string_value ( |
| 353 | const std::string &value, char *destination, int *len, int max_len, bool use_logger) |
| 354 | { |
| 355 | if ((destination == NULL) || (len == NULL) || (max_len < 1)) |
| 356 | { |
| 357 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 358 | } |
| 359 | |
| 360 | *len = (int)value.size (); |
| 361 | if (((int)value.size () + 1) > max_len) |
| 362 | { |
| 363 | destination[0] = '\0'; |
| 364 | if (use_logger) |
| 365 | { |
| 366 | Board::board_logger->error ("provided output buffer is too small, required {}, got {}", |
| 367 | value.size () + 1, max_len); |
| 368 | } |
| 369 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 370 | } |
| 371 | |
| 372 | memcpy (destination, value.c_str (), value.size () + 1); |
| 373 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 374 | } |
no outgoing calls
no test coverage detected