MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / string_remove_range

Function string_remove_range

string/std_string.c:2797–2817  ·  view source on GitHub ↗

* @brief Removes a range of characters from the String object. * * This function removes characters from the String object starting from @p startPos up to but not including @p endPos. * It adjusts the size of the String accordingly. If the String object or its data is NULL, or if the specified range * is invalid, the function logs an error and does nothing. * * @param str The String object f

Source from the content-addressed store, hash-verified

2795 * @param str The String object to check. Must not be NULL.
2796 * @param substr The substring to look for at the start of the String object. Must not be NULL.
2797 *
2798 * @return true if the String object starts with the specified substring, false otherwise.
2799 * Returns false if the String object, its data, or the substring is NULL.
2800 */
2801bool string_starts_with(const String* str, const char* substr) {
2802 STRING_LOG("[string_starts_with]: Function start.");
2803
2804 if (str == NULL) {
2805 STRING_LOG("[string_starts_with]: Error - The String object is NULL.");
2806 return false;
2807 }
2808 if (str->dataStr == NULL) {
2809 STRING_LOG("[string_starts_with]: Error - The dataStr of String object is NULL.");
2810 return false;
2811 }
2812 if (substr == NULL) {
2813 STRING_LOG("[string_starts_with]: Error - The substring is NULL.");
2814 return false;
2815 }
2816
2817 size_t substrLen = strlen(substr);
2818 if (substrLen > str->size) {
2819 STRING_LOG("[string_starts_with]: Substring is longer than the main string.");
2820 return false;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected