* @brief Returns a pointer to the first character in the String object. * * This function returns a pointer to the first character in the String object. If the String object is NULL or empty, * the function returns NULL. * * @param str The String object to access. Must not be NULL or empty. * @return A pointer to the first character in the string, or NULL if the string is NULL or empty. */
| 1375 | * @return A new C-string with all characters in lowercase. The caller is responsible for freeing the allocated memory. |
| 1376 | */ |
| 1377 | char* string_to_lower(const String* str) { |
| 1378 | if (str != NULL) { |
| 1379 | STRING_LOG("[string_to_lower]: Converting string to lowercase.\n"); |
| 1380 | |
| 1381 | char* lower = (char*) malloc(sizeof(char) * (str->size + 1)); |
| 1382 | if (!lower) { |
| 1383 | STRING_LOG("[string_to_lower]: Error - Failed to allocate memory.\n"); |
| 1384 | return NULL; |
| 1385 | } |
| 1386 | |
| 1387 | for (size_t index = 0; index < str->size; index++) { |
| 1388 | lower[index] = sstr_ascii_tolower(str->dataStr[index]); |
nothing calls this directly
no outgoing calls
no test coverage detected