pw_string: add pw::string::Copy methods

Adds pw::string::Copy helper methods as a safer alternative to
std::strncpy which unfortunately does not always null terminate.

In addition, the existing StringCopy methods are renamed to
StringOrNullCopy to denote that they support nullptr source strings
unlike pw::string::Copy.

Change-Id: I046c12da02721c5ad2f6601b9ac742d9dfa90c71
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/42931
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
11 files changed
tree: 91f5f76039e18b83ac754801cc8758b1e31a0571
  1. build_overrides/
  2. docker/
  3. docs/
  4. pw_allocator/
  5. pw_analog/
  6. pw_arduino_build/
  7. pw_assert/
  8. pw_assert_basic/
  9. pw_assert_log/
  10. pw_base64/
  11. pw_bloat/
  12. pw_blob_store/
  13. pw_boot_armv7m/
  14. pw_build/
  15. pw_bytes/
  16. pw_checksum/
  17. pw_chrono/
  18. pw_chrono_embos/
  19. pw_chrono_freertos/
  20. pw_chrono_stl/
  21. pw_chrono_threadx/
  22. pw_cli/
  23. pw_containers/
  24. pw_cpu_exception/
  25. pw_cpu_exception_cortex_m/
  26. pw_docgen/
  27. pw_doctor/
  28. pw_env_setup/
  29. pw_fuzzer/
  30. pw_hdlc/
  31. pw_hex_dump/
  32. pw_i2c/
  33. pw_interrupt/
  34. pw_interrupt_cortex_m/
  35. pw_kvs/
  36. pw_libc/
  37. pw_log/
  38. pw_log_basic/
  39. pw_log_multisink/
  40. pw_log_null/
  41. pw_log_rpc/
  42. pw_log_sink/
  43. pw_log_tokenized/
  44. pw_malloc/
  45. pw_malloc_freelist/
  46. pw_metric/
  47. pw_minimal_cpp_stdlib/
  48. pw_module/
  49. pw_multisink/
  50. pw_package/
  51. pw_persistent_ram/
  52. pw_polyfill/
  53. pw_preprocessor/
  54. pw_presubmit/
  55. pw_protobuf/
  56. pw_protobuf_compiler/
  57. pw_random/
  58. pw_result/
  59. pw_ring_buffer/
  60. pw_router/
  61. pw_rpc/
  62. pw_snapshot/
  63. pw_span/
  64. pw_status/
  65. pw_stream/
  66. pw_string/
  67. pw_sync/
  68. pw_sync_baremetal/
  69. pw_sync_embos/
  70. pw_sync_freertos/
  71. pw_sync_stl/
  72. pw_sync_threadx/
  73. pw_sys_io/
  74. pw_sys_io_arduino/
  75. pw_sys_io_baremetal_lm3s6965evb/
  76. pw_sys_io_baremetal_stm32f429/
  77. pw_sys_io_stdio/
  78. pw_target_runner/
  79. pw_thread/
  80. pw_thread_embos/
  81. pw_thread_freertos/
  82. pw_thread_stl/
  83. pw_thread_threadx/
  84. pw_tokenizer/
  85. pw_tool/
  86. pw_toolchain/
  87. pw_trace/
  88. pw_trace_tokenized/
  89. pw_unit_test/
  90. pw_varint/
  91. pw_watch/
  92. pw_web_ui/
  93. targets/
  94. third_party/
  95. .bazelignore
  96. .bazelrc
  97. .clang-format
  98. .eslintrc.json
  99. .gitattributes
  100. .gitignore
  101. .gn
  102. .prettierrc.js
  103. .pylintrc
  104. activate.bat
  105. AUTHORS
  106. bootstrap.bat
  107. bootstrap.sh
  108. BUILD
  109. BUILD.gn
  110. BUILDCONFIG.gn
  111. CMakeLists.txt
  112. LICENSE
  113. modules.gni
  114. OWNERS
  115. package.json
  116. PW_PLUGINS
  117. README.md
  118. tsconfig.json
  119. WORKSPACE
  120. yarn.lock
README.md

See our website: http://pigweed.dev