* @brief This function creates a new String object that contains the content of the input * String object `str` repeated `count` times. If `str` or its data is NULL, the function * returns NULL and logs an error. * * @param str The String object to repeat. Must not be NULL. * @param count The number of times to repeat the string. * * @return A new String object containing the repeated co
| 3254 | * |
| 3255 | * @return Returns `true` if the String object is a palindrome, `false` otherwise. |
| 3256 | * |
| 3257 | * @note If the String object is `NULL`, the function will print an error message |
| 3258 | * to `stderr` and return `false`. |
| 3259 | */ |
| 3260 | bool string_is_palindrome(const String* str) { |
| 3261 | STRING_LOG("[string_is_palindrome]: Function start."); |
| 3262 | if (!str) { |
| 3263 | STRING_LOG("[string_is_palindrome]: Error - str is NULL."); |
| 3264 | return false; |
| 3265 | } |
| 3266 | |
| 3267 | size_t str_size = string_length(str); |
| 3268 | if (str_size == 0) { |
| 3269 | STRING_LOG("[string_is_palindrome]: Empty string - returning true."); |
| 3270 | return true; |
| 3271 | } |
| 3272 | |
| 3273 | for (size_t i = 0, j = str_size - 1; i < str_size; i++, j--) { |
| 3274 | if (string_at(str, i) != string_at(str, j)) { |
| 3275 | STRING_LOG("[string_is_palindrome]: Mismatch found at index %zu - returning false.", i); |
| 3276 | return false; |
| 3277 | } |
| 3278 | } |
| 3279 | |
| 3280 | STRING_LOG("[string_is_palindrome]: String is a palindrome - returning true."); |
| 3281 | return true; |
| 3282 | } |
| 3283 | |
| 3284 | |
| 3285 | /** |
| 3286 | * @brief Checks if the given String object contains only alphanumeric characters. |
| 3287 | * |
| 3288 | * This function verifies whether the input String object consists solely of |
| 3289 | * alphanumeric characters (letters and digits). It returns `true` if all characters |
| 3290 | * are either alphabetic (`a-z`, `A-Z`) or numeric (`0-9`). If any non-alphanumeric character |
| 3291 | * is found, the function returns `false`. |
| 3292 | * |
nothing calls this directly
no test coverage detected