return string_equal_n( string, prefix, string_length( prefix ) );
}
+/// \brief Returns true if the ending of \p string is equal to \p suffix.
+/// O(n)
+inline bool string_equal_suffix( const char* string, const char* suffix){
+ const char *s = string + string_length( string ) - string_length( suffix );
+ return string_equal_n( s , suffix, string_length( suffix ) );
+}
+
/// \brief Copies \p other into \p string and returns \p string.
/// Assumes that the space allocated for \p string is at least string_length(other) + 1.
/// O(n)
return string_new( length, allocator );
}
+/// \brief Allocates a new buffer large enough to hold two concatenated strings and fills it with strings.
+inline char* string_new_concat( const char* a, const char* b ){
+ char* str = string_new( string_length( a ) + string_length( b ) );
+ strcpy( str, a );
+ strcat( str, b );
+ return str;
+}
+
/// \brief Deallocates the \p buffer large enough to hold \p length characters.
inline void string_release( char* string, std::size_t length ){
DefaultAllocator<char> allocator;