return memcmp(str1->data, str2->data, str1->used) == 0;
}
-void str_append_n(string_t *str, const void *cstr, size_t max_len)
+void str_append_max(string_t *str, const char *cstr, size_t max_len)
{
const char *p;
size_t len;
/* Append NUL-terminated string. If the trailing NUL isn't found earlier,
append a maximum of max_len characters. */
-void str_append_n(string_t *str, const void *cstr, size_t max_len);
+void str_append_max(string_t *str, const char *cstr, size_t max_len);
+static inline void
+str_append_n(string_t *str, const void *cstr, size_t max_len)
+{
+ str_append_max(str, cstr, max_len);
+}
static inline void str_append(string_t *str, const char *cstr)
{
test_end();
}
-static void test_str_append_n(void)
+static void test_str_append_max(void)
{
string_t *str = t_str_new(32);
- test_begin("str_append_n()");
- str_append_n(str, "foo", 0);
+ test_begin("str_append_max()");
+ str_append_max(str, "foo", 0);
test_assert(str->used == 0);
- str_append_n(str, "\0foo", 4);
+ str_append_max(str, "\0foo", 4);
test_assert(str->used == 0);
- str_append_n(str, "foo", 3);
+ str_append_max(str, "foo", 3);
test_assert(str->used == 3 && memcmp(str_data(str), "foo", 3) == 0);
str_truncate(str, 0);
- str_append_n(str, "foo", 2);
+ str_append_max(str, "foo", 2);
test_assert(str->used == 2 && memcmp(str_data(str), "fo", 2) == 0);
str_truncate(str, 0);
- str_append_n(str, "foo\0bar", 7);
+ str_append_max(str, "foo\0bar", 7);
test_assert(str->used == 3 && memcmp(str_data(str), "foo", 3) == 0);
str_truncate(str, 0);
test_end();
test_str_c();
test_str_insert();
test_str_delete();
- test_str_append_n();
+ test_str_append_max();
test_str_truncate();
}