* @brief Copy string data to memory allocated from alloc, then store pointer * and size into node. * @param s string pointer * @param len string length * @param alloc Allocator * @note: If failed when allocating memory, the node will be set as an empty * string. */
| 195 | * string. |
| 196 | */ |
| 197 | void StringCopy(const char* s, size_t len, alloc_type& alloc) { |
| 198 | sv.p = (char*)(alloc.Malloc(len + 1)); |
| 199 | if (sv.p) { |
| 200 | std::memcpy(const_cast<char*>(sv.p), s, len); |
| 201 | const_cast<char*>(sv.p)[len] = '\0'; |
| 202 | setLength(len, kStringFree); |
| 203 | } else { |
| 204 | setEmptyString(); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | // Check APIs |
| 209 | /** |
no test coverage detected